Skip to content

Commit 5eccc90

Browse files
feat:added sensitive files check
Signed-off-by: shiva <[email protected]>
1 parent 1544815 commit 5eccc90

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

.github/workflows/pr-check.yml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,50 @@ jobs:
2727
run: npm install
2828

2929
- name: NPM Build
30-
run: SERVER_ROOT=https://playground.accordproject.org && NODE_OPTIONS=--max_old_space_size=8192 npm run build
30+
run: SERVER_ROOT=https://playground.accordproject.org && NODE_OPTIONS=--max_old_space_size=8192 npm run build
31+
32+
check-sensitive-files:
33+
name: Check for Sensitive Files
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v2
38+
39+
- name: Get Changed Files
40+
id: get_changed_files
41+
uses: tj-actions/changed-files@v45
42+
43+
- name: Check for Unauthorized Changes
44+
run: |
45+
RESTRICTED_FILES=(
46+
".github/workflows/"
47+
"package.json"
48+
"package-lock.json"
49+
"Dockerfile"
50+
"docker-compose.yml"
51+
".env.example"
52+
)
53+
54+
UNAUTHORIZED_CHANGES=""
55+
56+
for file in ${{ steps.get_changed_files.outputs.all_changed_files }}; do
57+
for restricted in "${RESTRICTED_FILES[@]}"; do
58+
if [[ "$file" == *"$restricted"* ]]; then
59+
echo "❌ Unauthorized change detected: $file"
60+
UNAUTHORIZED_CHANGES="$UNAUTHORIZED_CHANGES\n$file"
61+
fi
62+
done
63+
done
64+
65+
if [[ ! -z "$UNAUTHORIZED_CHANGES" ]]; then
66+
echo -e "⛔ Unauthorized changes detected in:\n$UNAUTHORIZED_CHANGES"
67+
exit 1
68+
else
69+
echo "✅ No unauthorized changes detected. Proceeding..."
70+
fi
71+
shell: bash
72+
73+
74+
75+
76+

0 commit comments

Comments
 (0)