I have the following in my Github Actions YAML. It runs fine when the first check evaluates true,
- name: Check version is up to date
run: sh -c "
(git diff --quiet HEAD^ VERSION && git diff --quiet HEAD^ src/**) || \
! git diff --quiet HEAD^ src/VERSION
"
but when it evaluates false, the later sections gives me
sh: 1: !: not found
only in GitHub Actions. The command starting (and including) sh -c
doesn't error on my computer. I don't understand how that could be since I very explicitly mention the shell.
I think this is a formatting error/quirk. If I add a new line before the command, with the |
syntax, as
run: |
sh -c "
(git diff --quiet HEAD^ VERSION && git diff --quiet HEAD^ src/**) || \
! git diff --quiet HEAD^ src/VERSION
"
it works.