Route all API calls through bot PAT so posts are authored by opencode-bot, not forgejo-actions #2
Loading…
Reference in a new issue
No description provided.
Delete branch "opencode-1788172072.637961"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
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:
fixes #1
Co-authored-by: opencode opencode@noreply.localhost
/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 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
.curlrcchange — uses${API_PAT:-$FORGEJO_TOKEN}, correctly falls back to the ephemeral token if no PAT is set.API_PAT: ${{ inputs.api-pat || inputs.pr-creation-pat }}, so existing users with onlypr-creation-patkeep the old behavior (only PR creation authored by bot), whileapi-patenables the new behavior (everything authored by bot).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.-H "Authorization: Bearer $API_PAT"is now redundant with.curlrcbut harmless.Fix needed
Indent
api-patandpr-creation-patto 2 spaces (description/required at 4 spaces) to match the rest of theinputs:block.