-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: lugsociety <[email protected]>
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Validate Project Structure | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
validate: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.ref }} | ||
|
||
- name: Validate Structure | ||
run: | | ||
# Get the list of changed files in the push | ||
changed_files=$(git diff --name-only HEAD~1 HEAD) | ||
# Defined allowed Directories | ||
username="${{ github.actor }}" | ||
allowed_files=" | ||
^README.md | ||
^.gitignore | ||
^LICENSE | ||
^${username}/app.py | ||
^${username}/requirements.txt | ||
^${username}/README.md | ||
^${username}/static/ | ||
^${username}/static/css/ | ||
^${username}/static/js/ | ||
^${username}/templates/index.html | ||
" | ||
'^app.py|^requirements.txt|^README.md|^static/|^static/css/|^static/js/|^templates/index.html' | ||
# Check if there are any dirty files outside the allowed structure | ||
for file in $changed_files; do | ||
if ! [[ $file =~ $allowed_files ]]; then | ||
echo "Error: File $file is outside the allowed structure." | ||
exit 1 | ||
fi | ||
done | ||
- name: Success Message | ||
if: success() | ||
run: echo "All changes are within allowed structure." |