How to Comment on and Label Issues With a GitHub App Token
An App token lets a workflow comment and label as the App bot, keeping automation distinct from human accounts.
Comments and labels made with an App token are attributed to the App, which reads clearly in the timeline and avoids using a personal PAT. Grant issues: write (and pull-requests: write for PRs).
Steps
- Mint an App token with
issues: write/pull-requests: write. - Set
GH_TOKENand callgh issue comment/gh issue edit. - The action shows as the App bot in the timeline.
Workflow
.github/workflows/ci.yml
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh issue comment ${{ github.event.issue.number }} --body "Triaged automatically."
gh issue edit ${{ github.event.issue.number }} --add-label needs-reviewGotchas
- The App must be installed and hold
issues: writeon the repo. - Look up and update an existing comment to avoid duplicates on re-runs.
Related guides
How to Push to a Protected Branch With a GitHub App TokenLet a workflow commit to a protected branch by minting a GitHub App token and adding the App to the branch pr…
How to Authenticate the gh CLI With a Token in CIAuthenticate the GitHub CLI in CI by exporting GH_TOKEN, so gh commands run under a GitHub App installation t…