Created
April 12, 2024 21:21
-
-
Save ericclemmons/5adce288f14fb4e0324922c066c5f185 to your computer and use it in GitHub Desktop.
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
# https://github.com/dependabot/fetch-metadata#enabling-auto-merge | |
name: Auto-merge Dependabot | |
on: pull_request_target | |
permissions: | |
pull-requests: write | |
contents: write | |
jobs: | |
dependabot: | |
name: 'Dependabot' | |
runs-on: ubuntu-latest | |
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }} | |
permissions: | |
# Required for auto-merge – https://github.com/dependabot/fetch-metadata?tab=readme-ov-file#enabling-auto-merge | |
contents: write | |
# Required for auto-approving – https://github.com/dependabot/fetch-metadata?tab=readme-ov-file#auto-approving | |
pull-requests: write | |
steps: | |
- name: Dependabot metadata | |
id: metadata | |
uses: dependabot/fetch-metadata@v1 | |
- name: Enable auto-merge for Dependabot PRs | |
# Conditionals for when it's safe. For now, all passing checks is fine. | |
# if: ${{contains(steps.metadata.outputs.dependency-names, 'rails') && steps.metadata.outputs.update-type == 'version-update:semver-patch'}} | |
run: gh pr merge --auto --merge "$PR_URL" | |
env: | |
PR_URL: ${{github.event.pull_request.html_url}} | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
- uses: actions/checkout@v4 | |
- name: Approve a PR if not already approved | |
run: | | |
gh pr checkout "$PR_URL" # sets the upstream metadata for `gh pr status` | |
if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ]; | |
then gh pr review --approve "$PR_URL" | |
else echo "PR already approved, skipping additional approvals to minimize emails/notification noise."; | |
fi | |
env: | |
PR_URL: ${{github.event.pull_request.html_url}} | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment