From de4a8c95a95c2e1cff497c9861560b88943b7096 Mon Sep 17 00:00:00 2001 From: Loo Zheng Yuan Date: Sun, 29 Sep 2024 14:44:23 +0800 Subject: [PATCH] ci: enable auto-merge for Dependabot PRs --- .github/workflows/deps-automerge.yml | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/deps-automerge.yml diff --git a/.github/workflows/deps-automerge.yml b/.github/workflows/deps-automerge.yml new file mode 100644 index 0000000..3e90ef6 --- /dev/null +++ b/.github/workflows/deps-automerge.yml @@ -0,0 +1,36 @@ +name: deps-automerge + +on: + pull_request: + branches: + - main + +permissions: + contents: write + pull-requests: write + +defaults: + run: + # NOTE: Default option does not include `-o pipefail` as documented + # unless explicitly specifying the `bash` shell. + # https://github.com/actions/runner/issues/353 + shell: bash + +jobs: + automerge: + runs-on: ubuntu-22.04 + timeout-minutes: 2 + if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' && github.repository_owner == 'loozhengyuan' }} + + steps: + - name: Fetch Dependabot metadata + uses: dependabot/fetch-metadata@v2.2.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Enable auto-merge for Dependabot PRs + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_URL: ${{ github.event.pull_request.html_url }} + run: | + gh pr merge --auto --squash --delete-branch "${PR_URL}"