Skip to content

Commit 1209518

Browse files
committed
Fix grid workflow to check if new solutions are added
1 parent 19447e2 commit 1209518

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

.github/workflows/update-leetcode-grid.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@ jobs:
1515
steps:
1616
- name: Checkout repository
1717
uses: actions/checkout@v5
18-
with:
19-
ref: ${{ github.event.workflow_run.head_branch }}
2018

2119
- name: Check for Solutions/ changes
2220
id: changes
2321
run: |
24-
git fetch origin ${{ github.event.workflow_run.head_sha }}
25-
git diff --name-only ${{ github.event.workflow_run.head_sha }}^ ${{ github.event.workflow_run.head_sha }} > files.txt
22+
git fetch --depth=2 origin ${{ github.ref_name }}
23+
if git rev-parse HEAD^ >/dev/null 2>&1; then
24+
# Normal commit (has a parent)
25+
git diff --name-only HEAD^ HEAD > files.txt
26+
else
27+
# Root commit (no parent)
28+
git show --name-only --pretty="" HEAD > files.txt
29+
fi
30+
2631
if grep -q '^Solutions/' files.txt; then
2732
echo "changed=true" >> $GITHUB_OUTPUT
2833
else

0 commit comments

Comments
 (0)