Skip to content

feat: Added sensitive files check to CI pipeline #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
48 changes: 47 additions & 1 deletion .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,50 @@ jobs:
run: npm install

- name: NPM Build
run: SERVER_ROOT=https://playground.accordproject.org && NODE_OPTIONS=--max_old_space_size=8192 npm run build
run: SERVER_ROOT=https://playground.accordproject.org && NODE_OPTIONS=--max_old_space_size=8192 npm run build

check-sensitive-files:
name: Check for Sensitive Files
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Get Changed Files
id: get_changed_files
uses: tj-actions/changed-files@v45

- name: Check for Unauthorized Changes
run: |
RESTRICTED_FILES=(
".github/workflows/"
"package.json"
"package-lock.json"
"Dockerfile"
"docker-compose.yml"
".env.example"
)

UNAUTHORIZED_CHANGES=""

for file in ${{ steps.get_changed_files.outputs.all_changed_files }}; do
for restricted in "${RESTRICTED_FILES[@]}"; do
if [[ "$file" == *"$restricted"* ]]; then
echo "❌ Unauthorized change detected: $file"
UNAUTHORIZED_CHANGES="$UNAUTHORIZED_CHANGES\n$file"
fi
done
done

if [[ ! -z "$UNAUTHORIZED_CHANGES" ]]; then
echo -e "⛔ Unauthorized changes detected in:\n$UNAUTHORIZED_CHANGES"
exit 1
else
echo "✅ No unauthorized changes detected. Proceeding..."
fi
shell: bash