Skip to content

Commit

Permalink
Adding a validation step to look for file outside allowed folders
Browse files Browse the repository at this point in the history
  • Loading branch information
M-7th authored Oct 8, 2024
1 parent a863cd3 commit a06f1dd
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/validate_submission.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,45 @@ jobs:
echo "$file was changed"
done
# Look for file outside allowed folders
# ---------------------------------------
- name: Check if file are outside the allowed folders
run: |
# List of allowed folders
ALLOWED_FOLDERS=("model-output/" "model-metadata/")
# Init var for not allowed files
FILES_OUTSIDE_FOLDERS=""
# Iterate over changes
for FILE in $(echo ${{ steps.changed-files.outputs.all_changed_files }} | jq -r '.[]'); do
MATCH_FOUND=false
# Check if file is under an allowed folder
for FOLDER in "${ALLOWED_FOLDERS[@]}"; do
if [[ "$FILE" == "$FOLDER"* ]]; then
MATCH_FOUND=true
break
fi
done
# If not mathced, add to forbidden list
if [ "$MATCH_FOUND" = false ]; then
FILES_OUTSIDE_FOLDERS="${FILES_OUTSIDE_FOLDERS} $FILE"
fi
done
# If one or more file outside allowed folders are present, submission fails
if [ ! -z "$FILES_OUTSIDE_FOLDERS" ]; then
echo "Error: PR contains files outside the allowed folders."
echo "Files outside allowed folders: $FILES_OUTSIDE_FOLDERS"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


- uses: r-lib/actions/setup-r@v2
with:
install-r: false
Expand Down

0 comments on commit a06f1dd

Please sign in to comment.