CI: Fixup failure to get changed files on merge

The checkout might be too shallow so the before commit isn't available.
The logic was already written to take this into account (it then generates
an empty 'changed.txt' which falls back to testing everything), but the
error code would still force terminate the job.

Hopefully we can find a way to make the logic work for merge events too in
the future, but for now this is a quick fix.
This commit is contained in:
Rémi Verschelde 2023-04-20 17:51:53 +02:00
parent db13026370
commit 9063e907a7
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -30,9 +30,9 @@ jobs:
id: changed-files id: changed-files
run: | run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then if [ "${{ github.event_name }}" == "pull_request" ]; then
files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} 2> /dev/null) files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} 2> /dev/null || true)
elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then
files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null) files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true)
fi fi
echo "$files" >> changed.txt echo "$files" >> changed.txt
cat changed.txt cat changed.txt