Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/warn_supsect_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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 '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 caonstant.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
});
body: "⚠️ The file 'path/to/specific_file.txt' has been modified in this PR. Please review the changes carefully."
});

Loading