Skip to content

Commit 17565f8

Browse files
committed
[action] Only include merge message on sdk changes
The "Merge to main" workflow adds a comment to the PR so authors know that their changes shouldn't break the main branch, as it should always remain stable and releasable. This only makes sense when the change affects an SDK, as only those get released. Now we filter the message so it doesn't spam PRs that only touch infra (plugin & github folders)
1 parent 1e2e2c1 commit 17565f8

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

.github/workflows/merge-to-main.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,45 @@ on:
66
- main
77
types:
88
- opened
9-
- labeled
10-
- unlabeled
9+
- synchronize
1110

1211
jobs:
1312
pr-message:
1413
runs-on: ubuntu-latest
1514
permissions:
1615
pull-requests: write
1716
steps:
18-
- uses: mshick/add-pr-comment@b8f338c590a895d50bcbfa6c5859251edc8952fc # v2.8.2
17+
- name: Checkout repo
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
with:
20+
fetch-depth: 0
21+
submodules: false
22+
23+
- name: Filter paths
24+
id: filter
25+
run: |
26+
MERGE_BASE=$(git merge-base origin/${GITHUB_BASE_REF} origin/${GITHUB_HEAD_REF})
27+
FILES=$(git diff --name-only $MERGE_BASE origin/${GITHUB_HEAD_REF})
28+
IGNORE=true
29+
for FILE in $FILES; do
30+
if [[ $FILE != plugins/* && $FILE != .github/* ]]; then
31+
IGNORE=false
32+
break
33+
fi
34+
done
35+
36+
if $IGNORE; then
37+
echo "ignore=true" >> $GITHUB_OUTPUT
38+
echo "Filter result code: ignore = true"
39+
else
40+
echo "ignore=false" >> $GITHUB_OUTPUT
41+
echo "Filter result code: ignore = false"
42+
fi
43+
shell: bash
44+
45+
- name: Add PR comment
46+
if: steps.filter.outputs.ignore == 'false'
47+
uses: mshick/add-pr-comment@b8f338c590a895d50bcbfa6c5859251edc8952fc # v2.8.2
1948
with:
2049
message: >
2150
### 📝 PRs merging into main branch
@@ -27,4 +56,5 @@ jobs:
2756
branch when the code complete and ready to be released.
2857
2958
- name: Success
59+
if: steps.filter.outputs.ignore == 'false'
3060
run: exit 0

0 commit comments

Comments
 (0)