Skip to content

Commit

Permalink
Feat: add count-changed-files and check-unauthorized pr workflow (#2447)
Browse files Browse the repository at this point in the history
* Add count-changed-files and check-unauthorized pr workflow

* removed unwanted formatting changes
  • Loading branch information
lakshz authored Mar 28, 2024
1 parent 3a23de5 commit 73584a3
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,68 @@ jobs:
run: |
echo "PR is not against develop branch. Please refer PR_GUIDELINES.md"
exit 1
Check-Unauthorized-Changes:
name: Checks if no unauthorized files are changed
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get Changed Unauthorized files
id: changed-unauth-files
uses: tj-actions/changed-files@v40
with:
files: |
.github/**
env.example
.node-version
.husky/**
scripts/**
package.json
tsconfig.json
.gitignore
.eslintrc.json
.eslintignore
vite.config.ts
docker-compose.yaml
Dockerfile
CODEOWNERS
LICENSE
setup.ts
- name: List all changed unauthorized files
if: steps.changed-unauth-files.outputs.any_changed == 'true' || steps.changed-unauth-files.outputs.any_deleted == 'true'
env:
CHANGED_UNAUTH_FILES: ${{ steps.changed-unauth-files.outputs.all_changed_files }}
run: |
for file in ${CHANGED_UNAUTH_FILES}; do
echo "$file is unauthorized to change/delete"
done
exit 1
Count-Changed-Files:
name: Checks if number of files changed is acceptable
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40

- name: Echo number of changed files
env:
CHANGED_FILES_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}
run: |
echo "Number of files changed: $CHANGED_FILES_COUNT"
- name: Check if the number of changed files is less than 100
if: steps.changed-files.outputs.all_changed_files_count > 100
env:
CHANGED_FILES_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}
run: |
echo "Error: Too many files (greater than 100) changed in the pull request."
echo "Possible issues:"
echo "- Contributor may be merging into an incorrect branch."
echo "- Source branch may be incorrect please use develop as source branch."
exit 1

0 comments on commit 73584a3

Please sign in to comment.