Skip to content

Commit 1011f43

Browse files
committed
Added exemption code
1 parent 73b299b commit 1011f43

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

.github/workflows/block-changes.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,34 @@ jobs:
2626
else
2727
echo "CHANGES_DETECTED=false" >> $GITHUB_OUTPUT
2828
fi
29+
- name: Check for exemption for PR created by dot-org-content workflow
30+
id: check_exemption
31+
run: |
32+
LABELS=$(jq -r '.pull_request.labels[].name' "$GITHUB_EVENT_PATH" || echo "")
33+
AUTHOR=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
34+
TITLE=$(jq -r '.pull_request.title' "$GITHUB_EVENT_PATH")
35+
ACCEPTED_LABEL="module_reference"
36+
ACCEPTED_AUTHOR="github-actions"
37+
ACCEPTED_TITLE="NGINX Plus - Module Ref"
38+
39+
EXEMPTION=false
40+
41+
if echo "$LABELS" | grep -q "$ACCEPTED_LABEL"; then
42+
echo "Label match..."
43+
EXEMPTION=true
44+
fi
45+
if [[ "$AUTHOR" == "$ACCEPTED_AUTHOR" ]]; then
46+
echo "Author match..."
47+
EXEMPTION=true
48+
fi
49+
if [[ "$TITLE" == *"${ACCEPTED_TITLE}"* ]]; then
50+
echo "Title match..."
51+
EXEMPTION=true
52+
fi
53+
54+
echo "EXEMPTION=$EXEMPTION" >> $GITHUB_OUTPUT
2955
- name: Generate PR comment if changes detected
30-
if: steps.check_module_changes.outputs.CHANGES_DETECTED == 'true'
56+
if: steps.check_module_changes.outputs.CHANGES_DETECTED == 'true' && steps.check_exemption.outputs.EXEMPTION == 'false'
3157
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
3258
with:
3359
script: |
@@ -39,6 +65,6 @@ jobs:
3965
body: body,
4066
});
4167
- name: Fail job if changes detected
42-
if: steps.check_module_changes.outputs.CHANGES_DETECTED == 'true'
68+
if: steps.check_module_changes.outputs.CHANGES_DETECTED == 'true' && steps.check_exemption.outputs.EXEMPTION == 'false'
4369
run: |
4470
exit 0

0 commit comments

Comments
 (0)