ci(github): use app token for dependabot merges#171
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the Dependabot auto-merge GitHub Actions workflow to approve and enable auto-merge using a GitHub App token (instead of GITHUB_TOKEN), so merges triggered by Dependabot can properly trigger downstream workflows on main.
Changes:
- Added a SHA-pinned
actions/create-github-app-tokenstep to mint an app token for semver patch/minor Dependabot PRs. - Switched
gh pr review --approveandgh pr merge --auto --squashto use the generated app token viaGH_TOKEN. - Left
dependabot/fetch-metadatausing the defaultGITHUB_TOKEN.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| env: | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
|
|
| env: | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe657e2e50
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| app-id: ${{ secrets.DEPENDABOT_AUTOMERGE_APP_ID }} | ||
| private-key: ${{ secrets.DEPENDABOT_AUTOMERGE_PRIVATE_KEY }} |
There was a problem hiding this comment.
Store app credentials as Dependabot secrets
This job only runs for PRs opened by dependabot[bot], and GitHub exposes only Dependabot secrets to Dependabot-triggered workflows, not normal Actions secrets (see https://docs.github.com/en/code-security/reference/supply-chain-security/troubleshoot-dependabot/dependabot-on-actions#accessing-secrets). If DEPENDABOT_AUTOMERGE_APP_ID and DEPENDABOT_AUTOMERGE_PRIVATE_KEY are configured only as Actions secrets, this token step receives empty required inputs and every eligible patch/minor Dependabot PR fails before approval or auto-merge; mirror these names into Dependabot secrets or otherwise gate the workflow on available credentials.
Useful? React with 👍 / 👎.
| - name: Generate app token | ||
| id: app-token | ||
| if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' | ||
| uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2 |
Summary
Updates the Dependabot auto-merge workflow to use the LayeredCraft GitHub App token for approving and enabling auto-merge. This avoids using
GITHUB_TOKENfor the merge operation so downstream workflows can run after Dependabot auto-merged changes land onmain.Changes
actions/create-github-app-tokenstep for semver patch/minor Dependabot PRs.GH_TOKENforgh pr review --approveandgh pr merge --auto --squash.dependabot/fetch-metadataon the defaultGITHUB_TOKEN.Validation
Notes for Reviewers
Requires the Actions secrets
DEPENDABOT_AUTOMERGE_APP_IDandDEPENDABOT_AUTOMERGE_PRIVATE_KEYto be available to this repository.