Skip to content

Auto-merge Dependabot PRs #22

Auto-merge Dependabot PRs

Auto-merge Dependabot PRs #22

name: Auto-merge Dependabot PRs
on:
pull_request:
branches:
- develop
workflow_run:
workflows: ["CI"]
types:
- completed
permissions:
contents: write
pull-requests: write
jobs:
auto-merge:
runs-on: ubuntu-latest
if: |
github.actor == 'dependabot[bot]' &&
github.event_name == 'workflow_run' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Auto-merge Dependabot PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
run: |
# Get PR number from branch name
PR_NUMBER=$(echo "$HEAD_BRANCH" | grep -o '[0-9]\+' || echo '')
if [ -n "$PR_NUMBER" ]; then
# Approve PR
gh pr review $PR_NUMBER --approve
# Enable auto-merge
gh pr merge $PR_NUMBER --auto --merge
fi