From 26b57eaf7a9b804b97c37042d1d17f3595fef553 Mon Sep 17 00:00:00 2001 From: HavenDV Date: Tue, 10 Sep 2024 15:49:05 +0400 Subject: [PATCH] ci: Added auto-merge. --- .github/workflows/auto-merge.yml | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/auto-merge.yml diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml new file mode 100644 index 0000000..cf5141c --- /dev/null +++ b/.github/workflows/auto-merge.yml @@ -0,0 +1,40 @@ +name: Auto-approve and auto-merge bot pull requests +on: + pull_request: + branches: + - main + - master + +permissions: + contents: write + pull-requests: write + +jobs: + auto-merge: + runs-on: ubuntu-latest + if: ${{ (github.actor == 'dependabot[bot]' || github.actor == 'HavenDV') && github.repository_owner == 'HavenDV' }} + steps: + - name: Dependabot metadata + if: ${{ github.actor == 'dependabot[bot]' }} + id: metadata + uses: dependabot/fetch-metadata@0fb21704c18a42ce5aa8d720ea4b912f5e6babef + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Show sender + run: echo ${{ github.event.pull_request.sender }} + + - name: Show triggering_actor + run: echo ${{ github.triggering_actor }} + + - name: Approve a PR + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Enable auto-merge + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}