From 53fa8af122c0f111e0fb2bad76b8519c9bd904ac Mon Sep 17 00:00:00 2001 From: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> Date: Sun, 26 Feb 2023 01:51:25 +0530 Subject: [PATCH] feat: add automerger workflow Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> --- .github/workflows/automerger.yml | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/automerger.yml diff --git a/.github/workflows/automerger.yml b/.github/workflows/automerger.yml new file mode 100644 index 00000000..6b5cb98b --- /dev/null +++ b/.github/workflows/automerger.yml @@ -0,0 +1,43 @@ +name: 'Automerge Dependabot PRs' + +on: + workflow_run: + workflows: + - 'Lint PR' + - 'Continuous Integration' + - 'CodeQL' + types: + - completed + +permissions: + pull-requests: write + contents: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + - name: Dependabot metadata 🤖 + id: metadata + uses: dependabot/fetch-metadata@v1.3.6 + with: + alert-lookup: true + compat-lookup: true + github-token: ${{ secrets.DEPENDABOT_TOKEN }} + + - name: Authenticate CLI with PAT 🔐 + run: echo "${{ secrets.DEPENDABOT_TOKEN }}" | gh auth login --with-token + + - name: Approve Dependabot PRs 👍 + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.DEPENDABOT_TOKEN }} + + - name: Auto-merge Dependabot PRs 🕺 + if: steps.metadata.outputs.update-type == 'version-update:semver-minor' || 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.DEPENDABOT_TOKEN }}