File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -136,12 +136,18 @@ jobs:
136136 ancestor_commit=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
137137 files=$(git diff --diff-filter=AM --name-only $ancestor_commit ${{ github.event.pull_request.head.sha }})
138138 else
139- # Get changed files by comparing the current commit to the commit before the push event or with its parent:
139+ # Check if the commit SHA exists:
140+ if git rev-parse ${{ github.event.before }} >/dev/null 2>&1 && git rev-parse ${{ github.event.after }} >/dev/null 2>&1; then
141+ # Get changed files by comparing the current commit to the commit before the push event or with its parent:
140142 if [ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]; then
141143 files=$(git diff --diff-filter=AM --name-only HEAD~ ${{ github.event.after }})
142144 else
143145 files=$(git diff --diff-filter=AM --name-only ${{ github.event.before }} ${{ github.event.after }})
144146 fi
147+ else
148+ echo "Commit SHA not found, skipping file changes detection..."
149+ files=""
150+ fi
145151 fi
146152 directories=$(for file in $files; do dirname $file; done | uniq | tr '\n' ' ' | sed 's/ $//')
147153 echo "directories=${directories}" >> $GITHUB_OUTPUT
You can’t perform that action at this time.
0 commit comments