From a6183a5591b12b5d88ae12157fc443e270af30e3 Mon Sep 17 00:00:00 2001 From: Sebastian Schreck Date: Sun, 25 Aug 2024 12:56:58 +0200 Subject: [PATCH] Add automerge github action for dependabot --- .github/workflows/CI.yml | 2 +- .github/workflows/dependabot.yml | 45 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/dependabot.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index aceac30..26a4598 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -5,6 +5,7 @@ on: [push, pull_request] jobs: build: runs-on: ubuntu-latest + if: github.actor != 'dependabot[bot]' strategy: matrix: @@ -29,7 +30,6 @@ jobs: env: CI: true - name: Codacy Coverage Reporter - if: github.actor != 'dependabot[bot]' uses: codacy/codacy-coverage-reporter-action@v1.3.0 with: api-token: ${{ secrets.CODACY_API_TOKEN }} diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml new file mode 100644 index 0000000..696f037 --- /dev/null +++ b/.github/workflows/dependabot.yml @@ -0,0 +1,45 @@ +name: Dependabot auto-merge +on: pull_request + +permissions: + contents: 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@v2 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + - name: Checkout code + uses: actions/checkout@v3 + - name: Use Node.js latest + uses: actions/setup-node@v3 + with: + node-version: latest + - name: npm install, build, and test + run: | + cd uberpage + npm ci + npm run lint + npm test + cp -f src/data.github.js src/data.js + ../scripts/adjust_homepage.sh "https://stegschreck.github.io" + npm run build + env: + CI: true + - 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 for Dependabot PRs + if: steps.metadata.outputs.update-type != 'version-update:semver-major' + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GH_TOKEN: ${{secrets.GITHUB_TOKEN}}