-
Notifications
You must be signed in to change notification settings - Fork 28
54 lines (49 loc) · 1.8 KB
/
warn_supsect_pr.yml
File metadata and controls
54 lines (49 loc) · 1.8 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Alert on Specific File Change and Println Detection
on:
pull_request:
types:
- opened
- synchronize
jobs:
check-file-changes:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check for file changes
id: check_changes
run: |
if git diff --name-only HEAD^ HEAD | grep -E 'server/Cargo.toml|server/src/constants.rs'; then
echo "file_changed=true" >> $GITHUB_ENV
else
echo "file_changed=false" >> $GITHUB_ENV
fi
- name: Check for println occurrences
id: check_println
run: |
if git diff HEAD^ HEAD | grep -E 'println\!\('; then
echo "println_found=true" >> $GITHUB_ENV
else
echo "println_found=false" >> $GITHUB_ENV
fi
- name: Comment on PR if file changed or println detected
if: env.file_changed == 'true' || env.println_found == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let body = "";
if (process.env.file_changed === 'true') {
body += "⚠️ The file 'Cargo.toml or constant.rs' has been modified in this PR. Please review the changes carefully.\n";
}
if (process.env.println_found === 'true') {
body += "⚠️ A 'println!(' statement was found in the commit. Please ensure debug statements are removed before merging.\n";
}
github.rest.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});