From 3f85b18818d9833fc6837e89d2a0fbf2fd85700c Mon Sep 17 00:00:00 2001 From: Catalina Garcia Date: Tue, 31 Dec 2024 11:00:51 +0000 Subject: [PATCH] TMP: conditionally auto-approve dependabot PRs --- .github/workflows/dependabot-autoapprove.yml | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/dependabot-autoapprove.yml diff --git a/.github/workflows/dependabot-autoapprove.yml b/.github/workflows/dependabot-autoapprove.yml new file mode 100644 index 000000000..8f90ea986 --- /dev/null +++ b/.github/workflows/dependabot-autoapprove.yml @@ -0,0 +1,25 @@ +name: Dependabot auto-approve +on: pull_request +permissions: + pull-requests: write +jobs: + dependabot: + runs-on: ubuntu-latest + # Checking the author will prevent your Action run failing on non-Dependabot PRs + if: github.event.pull_request.user.login == 'dependabot[bot]' + steps: + - name: Dependabot metadata + id: dependabot-metadata + uses: dependabot/fetch-metadata@v2 + - uses: actions/checkout@v4 + - name: Approve a PR if not already approved + if: "!contains(steps.metadata.outputs.package-ecosystem, 'npm') && steps.metadata.outputs.update-type == 'version-update:semver-patch'" + 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 echo "This would approve the PR" + 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}} \ No newline at end of file