1
0
Fork 0
mirror of https://github.com/imjasonh/govulncheck-action synced 2026-07-16 20:25:16 +00:00
govulncheck-action/.github/workflows/dependabot-auto-merge.yml
Jason Hall a6757f0e87 ci: allow dependabot auto-merge on human rebases
Currently, the dependabot-auto-merge workflow (which rebuilds dist/) only runs if the actor is dependabot[bot]. If a human rebases a dependabot PR (e.g. via UI or CLI), this workflow is skipped, causing CI to fail because dist/ is out of sync.

This change:
1. Relaxes the condition to run on any branch starting with 'dependabot/', regardless of actor.
2. Adds workflow_dispatch trigger for manual fixes.
3. Updates CI workflow permissions.

Signed-off-by: Jason Hall <imjasonh@gmail.com>
2026-02-21 02:20:46 -05:00

55 lines
1.6 KiB
YAML

name: Dependabot auto-merge
on:
pull_request:
workflow_dispatch:
permissions:
contents: write
pull-requests: write
actions: write
jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' || startsWith(github.head_ref || github.ref_name, 'dependabot/') }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref || github.ref_name }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Rebuild dist
run: npm run build
- name: Commit and push changes
id: commit
run: |
if [ -n "$(git status --porcelain dist/)" ]; then
git config --global user.name "dependabot[bot]"
git config --global user.email "49699333+dependabot[bot]@users.noreply.github.com"
git add dist/
git commit -m "chore: rebuild dist"
git push
echo "pushed=true" >> "$GITHUB_OUTPUT"
fi
- name: Trigger CI
if: steps.commit.outputs.pushed == 'true'
run: gh workflow run ci.yml --ref ${{ github.event.pull_request.head.ref || github.ref_name }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url || github.ref_name }}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}