File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11name : Line Length Check
22
33on :
4- push :
5- branches :
6- - dev
74 pull_request :
85 branches :
6+ - dev
97 - staging
108
119jobs :
@@ -14,21 +12,27 @@ jobs:
1412
1513 steps :
1614 - name : Checkout code
17- uses : actions/checkout@v5
15+ uses : actions/checkout@v4
1816 with :
1917 fetch-depth : 0
2018
2119 - name : Fail on lines over 120 characters
2220 env :
23- BASE_SHA : ${{ github.event.pull_request.base.sha }}
24- HEAD_SHA : ${{ github.event.pull_request.head.sha }}
21+ BASE_REF : ${{ github.base_ref }}
2522 run : |
2623 set -euo pipefail
2724
2825 max_length=120
2926 has_errors=0
3027
31- mapfile -t files < <(git diff --name-only --diff-filter=AM "$BASE_SHA" "$HEAD_SHA")
28+ if [ -z "$BASE_REF" ]; then
29+ echo "BASE_REF is empty; this workflow only supports pull_request events."
30+ exit 1
31+ fi
32+
33+ git fetch --no-tags --depth=1 origin "$BASE_REF"
34+
35+ mapfile -t files < <(git diff --name-only --diff-filter=AM "origin/$BASE_REF...HEAD")
3236
3337 if [ "${#files[@]}" -eq 0 ]; then
3438 echo "No added or modified files to check."
You can’t perform that action at this time.
0 commit comments