From 3a17a88f1f800a121bb3a0d74ba0888789eca99b Mon Sep 17 00:00:00 2001 From: Mukilan Thiyagarajan Date: Thu, 24 Aug 2023 20:28:25 +0530 Subject: [PATCH] Auto approve & merge dependabot patch upgrade PRs (#30191) Adapted from the [Github documentation][doc]. This version approves all patch upgrades to any dependency. Not sure if we have any dependency that must always be reviewed manually. [doc]: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions Signed-off-by: Mukilan Thiyagarajan --- .github/workflows/dependabot-pr.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/dependabot-pr.yml diff --git a/.github/workflows/dependabot-pr.yml b/.github/workflows/dependabot-pr.yml new file mode 100644 index 00000000000..40df151db7f --- /dev/null +++ b/.github/workflows/dependabot-pr.yml @@ -0,0 +1,25 @@ +name: Approve & merge successful dependabot patch upgrade PRs +on: pull_request + +permissions: + content: write + pull-requests: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v1 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + - name: Approve the PR & enable auto-merge + if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' }} + run: | + gh pr review --approve "$PR_URL" + gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}