Skip to content

Commit 73b299b

Browse files
committed
Add code to comment on PR + fail if changes detected
1 parent 9b6a813 commit 73b299b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

.github/workflows/block-changes.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ jobs:
77
block-direct-markdown-module-changes:
88
name: Block modifying Markdown Module Reference files directly
99
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
1012
steps:
1113
- name: Checkout repository
1214
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # v4.2.2
@@ -24,7 +26,19 @@ jobs:
2426
else
2527
echo "CHANGES_DETECTED=false" >> $GITHUB_OUTPUT
2628
fi
27-
- name: Fail job and generate PR comment if changes detected
29+
- name: Generate PR comment if changes detected
30+
if: steps.check_module_changes.outputs.CHANGES_DETECTED == 'true'
31+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
32+
with:
33+
script: |
34+
const body = `This PR is blocked from being reviewed. Please make direct changes to module_references from the upstream XML in https://github.com/nginx/nginx.org`;
35+
await github.rest.issues.createComment({
36+
issue_number: context.issue.number,
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
body: body,
40+
});
41+
- name: Fail job if changes detected
2842
if: steps.check_module_changes.outputs.CHANGES_DETECTED == 'true'
2943
run: |
30-
echo "Hi"
44+
exit 0

0 commit comments

Comments
 (0)