From 48ba64817570802f7d03b08dd71da7f9239d1e4c Mon Sep 17 00:00:00 2001 From: Pugma Date: Tue, 15 Oct 2024 16:46:01 +0900 Subject: [PATCH] impl: auto patch merge --- .github/workflows/auto-merge.yaml | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/auto-merge.yaml diff --git a/.github/workflows/auto-merge.yaml b/.github/workflows/auto-merge.yaml new file mode 100644 index 00000000..e903f925 --- /dev/null +++ b/.github/workflows/auto-merge.yaml @@ -0,0 +1,32 @@ +name: Auto Merge (Dependabot) + +on: + pull_request: + branches: 'main' + +permissions: + contents: write + pull-requests: write + +jobs: + AutoMerge: + name: Approve patch PR + runs-on: ubuntu-latest + if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'owner/my_repo' + steps: + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v2.2.0 + with: + github-token: '${{ secrets.GITHUB_TOKEN }}' + - name: Approve a PR + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Enable auto-merge for Dependabot PRs + if: contains(steps.metadata.outputs.dependency-names, 'my-dependency') && 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}} + GH_TOKEN: ${{secrets.GITHUB_TOKEN}}