I’ve got an action that runs on PR’s that are going from "release/**" into master that incriments the RC version each time it runs and commits it back into the release branch.
To stop a loop starting, I have the following step
- name: Check if version number has changed
run: |
if [[ $(git show HEAD | grep -e ""version":.*-rc..*") ]]; then
echo "Version number has changed, moving onto next jobs"
exit 1
else
echo "Version number has not changed, continuing with this job"
fi
However, when running, it just responds with
1: [[: not found
Version number has not changed, continuing with this job
With the result being the infinite loop that I’m trying to avoid.
This was initially running on a node:lts
container, but I switched it to ubuntu:latest
when I started hitting this issue to try and remedy it, to no avail. I’ve also tried adding #!/bin/bash
to the top of the step.
How can I get around this? The if statement works perfectly when ran locally on my WSL ubuntu install.
2
Answers
As @jessehouwing said to do, running with
shell: bash
fixed the issueThis is the working form of the above step.
You could put your logic into its own bash script and then
run:
the bash script in the action