Route all API calls through bot PAT so posts are authored by opencode-bot, not forgejo-actions #2

Merged
opencode merged 2 commits from opencode-1788172072.637961 into main 2026-08-31 12:34:12 +02:00
Collaborator

Summary

This change ensures all API calls (reactions, comments, PR creation, branch comments) are
authenticated using the bot's Personal Access Token (PAT), so all posts appear as
authored by opencode-bot instead of forgejo-actions.

Changes

  • Added new api-pat input for the bot's Personal Access Token
  • Modified .curlrc to use api-pat with fallback to FORGEJO_TOKEN
  • Updated PR creation step to use api-pat (with fallback to pr-creation-pat for backward compatibility)
  • Updated documentation strings to reference api-pat instead of pr-creation-pat
  • Marked pr-creation-pat as deprecated

Backward Compatibility

The pr-creation-pat input is still supported for backward compatibility. If api-pat is
not provided, the action will fall back to pr-creation-pat for PR creation. For all
other API calls, it will fall back to FORGEJO_TOKEN.

Requirements

The PAT user (e.g., opencode-bot) needs:

  • Read access to repositories (for GET calls: issues, comments, PR reviews)
  • Write access to repositories (for POST calls: comments, reactions, PR creation)

fixes #1

Co-authored-by: opencode opencode@noreply.localhost

## Summary This change ensures all API calls (reactions, comments, PR creation, branch comments) are authenticated using the bot's Personal Access Token (PAT), so all posts appear as authored by opencode-bot instead of forgejo-actions. ## Changes - Added new api-pat input for the bot's Personal Access Token - Modified .curlrc to use api-pat with fallback to FORGEJO_TOKEN - Updated PR creation step to use api-pat (with fallback to pr-creation-pat for backward compatibility) - Updated documentation strings to reference api-pat instead of pr-creation-pat - Marked pr-creation-pat as deprecated ## Backward Compatibility The pr-creation-pat input is still supported for backward compatibility. If api-pat is not provided, the action will fall back to pr-creation-pat for PR creation. For all other API calls, it will fall back to FORGEJO_TOKEN. ## Requirements The PAT user (e.g., opencode-bot) needs: - Read access to repositories (for GET calls: issues, comments, PR reviews) - Write access to repositories (for POST calls: comments, reactions, PR creation) fixes #1 Co-authored-by: opencode <opencode@noreply.localhost>
## Summary
This change ensures all API calls (reactions, comments, PR creation, branch comments) are
authenticated using the bot's Personal Access Token (PAT), so all posts appear as
authored by opencode-bot instead of forgejo-actions.

## Changes
- Added new api-pat input for the bot's Personal Access Token
- Modified .curlrc to use api-pat with fallback to FORGEJO_TOKEN
- Updated PR creation step to use api-pat (with fallback to pr-creation-pat for backward compatibility)
- Updated documentation strings to reference api-pat instead of pr-creation-pat
- Marked pr-creation-pat as deprecated

## Backward Compatibility
The pr-creation-pat input is still supported for backward compatibility. If api-pat is
not provided, the action will fall back to pr-creation-pat for PR creation. For all
other API calls, it will fall back to FORGEJO_TOKEN.

## Requirements
The PAT user (e.g., opencode-bot) needs:
- Read access to repositories (for GET calls: issues, comments, PR reviews)
- Write access to repositories (for POST calls: comments, reactions, PR creation)

fixes #1

Co-authored-by: opencode <opencode@noreply.localhost>
Author
Collaborator

/opencode

The logic in this PR is sound and the backward-compat approach is clean, but there is a blocking YAML indentation bug that will prevent the action from parsing.

The bug

The two new input definitions use 3-space indentation instead of the 2-space indentation used by every other input in the file:

inputs:
  model:                          # 2 spaces ✓
    description: ...              # 4 spaces ✓
    required: true

   api-pat:                       # 3 spaces ✗
     description: ...             # 5 spaces ✗
     required: false

   pr-creation-pat:               # 3 spaces ✗
     description: ...             # 5 spaces ✗
     required: false

YAML requires consistent indentation within a mapping level. Mixing 2-space and 3-space keys under inputs: is a syntax error — Forgejo will fail to load the action.

What's good

  • .curlrc change — uses ${API_PAT:-$FORGEJO_TOKEN}, correctly falls back to the ephemeral token if no PAT is set.
  • Backward compat — the Create PR step uses API_PAT: ${{ inputs.api-pat || inputs.pr-creation-pat }}, so existing users with only pr-creation-pat keep the old behavior (only PR creation authored by bot), while api-pat enables the new behavior (everything authored by bot).
  • The if [ -z "$API_PAT" ] check correctly uses the combined value, so the "drop a branch comment" fallback still works for users with neither input set.
  • The PR creation curl's explicit -H "Authorization: Bearer $API_PAT" is now redundant with .curlrc but harmless.

Fix needed

Indent api-pat and pr-creation-pat to 2 spaces (description/required at 4 spaces) to match the rest of the inputs: block.

/opencode The logic in this PR is sound and the backward-compat approach is clean, but there is a **blocking YAML indentation bug** that will prevent the action from parsing. ## The bug The two new input definitions use **3-space indentation** instead of the 2-space indentation used by every other input in the file: ```yaml inputs: model: # 2 spaces ✓ description: ... # 4 spaces ✓ required: true api-pat: # 3 spaces ✗ description: ... # 5 spaces ✗ required: false pr-creation-pat: # 3 spaces ✗ description: ... # 5 spaces ✗ required: false ``` YAML requires consistent indentation within a mapping level. Mixing 2-space and 3-space keys under `inputs:` is a syntax error — Forgejo will fail to load the action. ## What's good - **`.curlrc` change** — uses `${API_PAT:-$FORGEJO_TOKEN}`, correctly falls back to the ephemeral token if no PAT is set. - **Backward compat** — the Create PR step uses `API_PAT: ${{ inputs.api-pat || inputs.pr-creation-pat }}`, so existing users with only `pr-creation-pat` keep the old behavior (only PR creation authored by bot), while `api-pat` enables the new behavior (everything authored by bot). - The `if [ -z "$API_PAT" ]` check correctly uses the combined value, so the "drop a branch comment" fallback still works for users with neither input set. - The PR creation curl's explicit `-H "Authorization: Bearer $API_PAT"` is now redundant with `.curlrc` but harmless. ## Fix needed Indent `api-pat` and `pr-creation-pat` to 2 spaces (description/required at 4 spaces) to match the rest of the `inputs:` block.
Change indentation from 3 spaces to 2 spaces for api-pat and
pr-creation-pat input definitions to match the 2-space indentation
used by all other inputs in the file. This fixes a YAML syntax error
that would prevent Forgejo from parsing the action.

Co-authored-by: opencode <opencode@noreply.localhost>
opencode deleted branch opencode-1788172072.637961 2026-08-31 12:34:13 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
michael/forgejo-opencode!2
No description provided.