Auto-merge Dependabot PRs #29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} | |
| run: | | |
| # Get PR number from the workflow run event | |
| PR_NUMBER=${{ github.event.workflow_run.pull_requests[0].number }} | |
| if [ -n "$PR_NUMBER" ]; then | |
| # Approve PR | |
| gh pr review $PR_NUMBER --approve | |
| # Enable auto-merge | |
| gh pr merge $PR_NUMBER --auto --merge | |
| fi |