-
Notifications
You must be signed in to change notification settings - Fork 3
40 lines (31 loc) · 1.16 KB
/
fragments-check.yml
File metadata and controls
40 lines (31 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Fragments check
on:
pull_request:
types: [labeled, unlabeled, opened, reopened, synchronize]
branches:
- main
jobs:
check-fragment-added:
if: github.event.pull_request.user.type != 'Bot' && !contains(github.event.pull_request.labels.*.name, 'skip-fragment-check')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: '0'
- name: Check if linked to the correct pull request
run: |
diff=$(git diff origin/${{ github.base_ref }} HEAD --name-only)
changelog_fragments=$(echo "$diff" | grep "^.changes/unreleased/.*\.yaml$")
pr_number=${{ github.event.pull_request.number }}
found_match=false
for file in $changelog_fragments; do
if grep -qE "PR: *\"?$pr_number\"?" "$file"; then
echo "✅ Found PR number $pr_number in $file"
found_match=true
fi
done
if [ "$found_match" = false ]; then
echo "❌ No matching PR number found in changelog fragments."
exit 1
fi