Skip to content

Commit c5e8b52

Browse files
committed
workflow fix
1 parent 05a1eab commit c5e8b52

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

.github/workflows/line-length-check.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
name: Line Length Check
22

33
on:
4-
push:
5-
branches:
6-
- dev
74
pull_request:
85
branches:
6+
- dev
97
- staging
108

119
jobs:
@@ -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."

0 commit comments

Comments
 (0)