Skip to content

Commit 4f7c410

Browse files
authored
automerge solution based on labeler (#1022)
1 parent 1cc81e1 commit 4f7c410

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

.github/labeler.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 1
2+
labels:
3+
- label: "automerge"
4+
authors: ["softwaremill-ci"]
5+
files:
6+
- "build.sbt"
7+
- "project/plugins.sbt"
8+
- label: "dependency"
9+
authors: ["softwaremill-ci"]
10+
files:
11+
- "build.sbt"
12+
- "project/plugins.sbt"

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,41 @@ jobs:
321321

322322
- name: Publish JVM native docker image
323323
run: sbt "project nativeServer; assembly; Docker / publish"
324+
325+
# `automerge` label is attached iff there is exactly one file changed by steward and this file belongs to a
326+
# whitelist specified by `labeler.yml`
327+
label:
328+
name: Attach automerge label
329+
# only for PRs by softwaremill-ci
330+
if: github.event.pull_request.user.login == 'softwaremill-ci'
331+
runs-on: ubuntu-20.04
332+
steps:
333+
- uses: actions/checkout@v3
334+
with:
335+
fetch-depth: 2
336+
# count number of files changed
337+
- name: Count number of files changed
338+
id: count-changed-files
339+
run: |
340+
N=$(git diff --name-only -r HEAD^1 HEAD | wc -w)
341+
echo "changed_files_num=$N" >> $GITHUB_OUTPUT
342+
- name: Launch labeler
343+
# skip if more than one file changed
344+
if: steps.count-changed-files.outputs.changed_files_num == 1
345+
uses: srvaroa/labeler@master
346+
env:
347+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
348+
349+
auto-merge:
350+
name: Auto merge
351+
# only for PRs by softwaremill-ci
352+
if: github.event.pull_request.user.login == 'softwaremill-ci'
353+
needs: [ci-2-12, ci-2-13, ci-3, ci-docker, ci-native-image-agent-config-verification, label]
354+
runs-on: ubuntu-20.04
355+
steps:
356+
- id: automerge
357+
name: automerge
358+
uses: "pascalgn/[email protected]"
359+
env:
360+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
361+
MERGE_METHOD: "squash"

0 commit comments

Comments
 (0)