From 05a8fe9aacc2711222c2798a269ea1ad42ff3d3c Mon Sep 17 00:00:00 2001 From: kciesielski Date: Fri, 12 Jul 2024 09:13:43 +0200 Subject: [PATCH] Replace mergify with automerge action --- .github/labeler.yml | 12 +++++++++ .github/workflows/ci.yml | 38 ++++++++++++++++++++++++++++ .mergify.yml | 54 ---------------------------------------- 3 files changed, 50 insertions(+), 54 deletions(-) create mode 100644 .github/labeler.yml delete mode 100644 .mergify.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000..4f1047b0 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,12 @@ +version: 1 +labels: + - label: "automerge" + authors: ["softwaremill-ci"] + files: + - "build.sbt" + - "project/plugins.sbt" + - label: "dependency" + authors: ["softwaremill-ci"] + files: + - "build.sbt" + - "project/plugins.sbt" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2cc8c4d1..db931330 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,6 +52,44 @@ jobs: - name: Check MiMa # disable for major releases run: sbt -v core3/mimaReportBinaryIssues + # `automerge` label is attached iff there is exactly one file changed by steward and this file belongs to a + # whitelist specified by `labeler.yml` + label: + name: Attach automerge label + # only for PRs by softwaremill-ci + if: github.event.pull_request.user.login == 'softwaremill-ci' + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + # count number of files changed + - name: Count number of files changed + id: count-changed-files + run: | + N=$(git diff --name-only -r HEAD^1 HEAD | wc -w) + echo "changed_files_num=$N" >> $GITHUB_OUTPUT + - name: Launch labeler + # skip if more than one file changed + if: steps.count-changed-files.outputs.changed_files_num == 1 + uses: srvaroa/labeler@master + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + auto-merge: + name: Auto merge + # only for PRs by softwaremill-ci + if: github.event.pull_request.user.login == 'softwaremill-ci' + needs: [ ci, mima, label ] + runs-on: ubuntu-22.04 + steps: + - id: automerge + name: automerge + uses: "pascalgn/automerge-action@v0.16.3" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + MERGE_METHOD: "squash" + publish: name: Publish release needs: [ci] diff --git a/.mergify.yml b/.mergify.yml deleted file mode 100644 index 6074b01c..00000000 --- a/.mergify.yml +++ /dev/null @@ -1,54 +0,0 @@ -pull_request_rules: - - name: delete head branch after merge - conditions: [] - actions: - delete_head_branch: {} - - name: automatic merge for softwaremill-ci pull requests affecting build.sbt - conditions: - - author=softwaremill-ci - - check-success=ci - - check-success=mima - - "#files=1" - - files=build.sbt - actions: - merge: - method: merge - - name: automatic merge for softwaremill-ci pull requests affecting project plugins.sbt - conditions: - - author=softwaremill-ci - - check-success=ci - - check-success=mima - - "#files=1" - - files=project/plugins.sbt - actions: - merge: - method: merge - - name: semi-automatic merge for softwaremill-ci pull requests - conditions: - - author=softwaremill-ci - - check-success=ci - - check-success=mima - - "#approved-reviews-by>=1" - actions: - merge: - method: merge - - name: automatic merge for softwaremill-ci pull requests affecting project build.properties - conditions: - - author=softwaremill-ci - - check-success=ci - - check-success=mima - - "#files=1" - - files=project/build.properties - actions: - merge: - method: merge - - name: automatic merge for softwaremill-ci pull requests affecting .scalafmt.conf - conditions: - - author=softwaremill-ci - - check-success=ci - - check-success=mima - - "#files=1" - - files=.scalafmt.conf - actions: - merge: - method: merge