File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments