Skip to content
Latchkey

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_TOKEN and call gh 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-review

Gotchas

  • The App must be installed and hold issues: write on the repo.
  • Look up and update an existing comment to avoid duplicates on re-runs.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →