in github action I have an if, but I still need to run someother thing if I'm in the else case. Is there a clean way to do it or do I have to do another step with the same condition at false?
- if: contains(['SNAPSHOT'],env.BUILD_VERSION) name:IF run: echo ":)" - if: false == contains(['SNAPSHOT'], env.BUILD_VERSION) name: Else run: echo ":("
GitHub Actions doesn't have else statement to run a different command/action/code. But you're right, all what you need to do is to create another step with reversed if condition. BTW, you can just use !
You can configure a GitHub Actions workflow to be triggered when an event occurs in your repository, such as a pull request being opened or an issue being created. Your workflow contains one or more jobs which can run in sequential order or in parallel.
To set a custom environment variable, you must define it in the workflow file. The scope of a custom environment variable is limited to the element in which it is defined. You can define environment variables that are scoped for: The entire workflow, by using env at the top level of the workflow file.
GitHub uses the exit code to set the action's check run status, which can be success or failure . The action completed successfully and other tasks that depends on it can begin. Any other exit code indicates the action failed. When an action fails, all concurrent actions are canceled and future actions are skipped.
GitHub Actions doesn't have else statement to run a different command/action/code. But you're right, all what you need to do is to create another step with reversed if condition. BTW, you can just use !
instead of false ==
, if you surround your statement with ${{ }}
.
Here are some links: if statement, operators
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With