11name : 📊 Static Checks
22on :
33 workflow_call :
4+ inputs :
5+ event-name :
6+ description : The caller's `github.event_name` value.
7+ type : string
8+ required : true
49
510jobs :
611 static-checks :
@@ -18,20 +23,28 @@ jobs:
1823 run : |
1924 bash ./misc/scripts/gitignore_check.sh
2025
26+ - name : Get branch name
27+ id : branch-name
28+ uses : tj-actions/branch-names@v9
29+
30+ - name : Get last successful commit
31+ id : last-successful-commit
32+ uses : nrwl/nx-set-shas@v4
33+ with :
34+ main-branch-name : ${{ inputs.event-name == "pull" && steps.branch-name.outputs.current_branch || steps.branch-name.outputs.base_ref_branch }}
35+
2136 - name : Get changed files
22- env :
23- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
24- run : |
25- if [ "${{ github.event_name }}" == "pull_request" ]; then
26- files=$(git diff-tree --no-commit-id --name-only -r HEAD^1..HEAD 2> /dev/null || true)
27- elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then
28- files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true)
29- fi
30- files=$(echo "$files" | xargs -I {} sh -c 'echo "\"./{}\""' | tr '\n' ' ')
31- echo "CHANGED_FILES=$files" >> $GITHUB_ENV
37+ id : changed-files
38+ uses : tj-actions/changed-files@v47
39+ with :
40+ base_sha : ${{ steps.last-successful-commit.outputs.base }} # Compare against last successful commit.
41+ separator : ' " "' # To account for paths with spaces, ensure our items are split by quotes internally.
42+ safe_output : false # Output passed to environment variable to avoid command injection.
3243
3344 - name : Style checks via pre-commit
3445 uses : pre-commit/action@v3.0.1
46+ env :
47+ CHANGED_FILES : ' "${{ steps.changed-files.outputs.all_changed_files }}"' # Wrap with quotes to bookend internal quote separators.
3548 with :
3649 extra_args : --files ${{ env.CHANGED_FILES }}
3750
0 commit comments