Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,24 @@ jobs:
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- 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
with:
app-id: ${{ secrets.DEPENDABOT_AUTOMERGE_APP_ID }}
private-key: ${{ secrets.DEPENDABOT_AUTOMERGE_PRIVATE_KEY }}
Comment on lines +27 to +28

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Move app-token secrets off pull_request_target

Because this job only runs for Dependabot-authored pull_request_target events, GitHub's Dependabot secret restrictions mean secrets are not available in this workflow context. The newly added app-id/private-key are required by actions/create-github-app-token, so they resolve empty and the step fails before approval or auto-merge for every eligible Dependabot PR; use a pull_request/two-step workflow that can read Dependabot secrets, or avoid secrets under pull_request_target.

Useful? React with 👍 / 👎.


- name: Approve PR
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor'
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ steps['app-token'].outputs.token }}

- name: Enable auto-merge for Dependabot PRs
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor'
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ steps['app-token'].outputs.token }}
Loading