Auto merge Dependabot PR #5445
This file contains 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
# From @UziTech | |
# https://github.com/dependabot/dependabot-core/issues/2268#issuecomment-831376155 | |
name: Auto merge Dependabot PR | |
on: | |
workflow_run: | |
workflows: | |
- CI | |
types: | |
- completed | |
jobs: | |
auto-merge: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: 'Merge PR' | |
uses: actions/github-script@v4 | |
with: | |
github-token: ${{ secrets.DEPENDABOT_AUTO_MERGE_TOKEN }} | |
script: | | |
if (context.payload.workflow_run.pull_requests.length > 0) { | |
const pr = await github.pulls.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.payload.workflow_run.pull_requests[0].number, | |
}); | |
if (pr.data.title.startsWith('build(deps') && pr.data.user.login === 'dependabot[bot]') { | |
await github.pulls.merge({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.payload.workflow_run.pull_requests[0].number, | |
}); | |
console.log('Merged 🎉'); | |
} else { | |
console.log('Not Merged 🚫'); | |
} | |
} else { | |
console.log('Not Merged 🚫'); | |
} |