Skip to content

Commit 7e2a917

Browse files
committed
fix: github auto publish workflow check condition
1 parent 15499b4 commit 7e2a917

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

.github/workflows/vsce-publish.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,21 @@ jobs:
1818
ref: refs/heads/master
1919
fetch-depth: 2
2020

21-
- name: Determine if package.json changed in the last commit
21+
- name: Determine if package.json changed in the last 24 hours
2222
id: pkg_changed
2323
run: |
24-
# if there is a previous commit available (fetch-depth:2 gives HEAD~1), diff only the root package.json
25-
if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then
26-
CHANGED=$(git diff --name-only HEAD~1 HEAD -- package.json || true)
27-
else
28-
# fallback: list top-level files only (no -r) and match exact 'package.json' to avoid subfolder matches
29-
CHANGED=$(git ls-tree --name-only HEAD | grep -x 'package.json' || true)
24+
# Look for any commits touching package.json in the last 24 hours.
25+
# If this is a shallow clone, try to fetch more history and retry.
26+
CHANGED=$(git log --since="24 hours ago" --pretty=format:%H -- package.json || true)
27+
28+
if [ -z "$CHANGED" ]; then
29+
# If the repo may be shallow, try to unshallow or fetch more history and retry
30+
if git rev-parse --is-shallow-repository >/dev/null 2>&1 && [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
31+
git fetch --prune --unshallow || git fetch --prune --depth=50 origin || true
32+
fi
33+
CHANGED=$(git log --since="24 hours ago" --pretty=format:%H -- package.json || true)
3034
fi
35+
3136
if [ -n "$CHANGED" ]; then
3237
echo "changed=true" >> $GITHUB_OUTPUT
3338
else

0 commit comments

Comments
 (0)