Checking outputs #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Checking outputs | |
on: | |
workflow_dispatch: | |
jobs: | |
job1: | |
runs-on: ubuntu-latest | |
outputs: | |
my_output: ${{ steps.job1.outputs.my_output }} | |
steps: | |
- name: Set some value | |
id: job1 | |
run: | | |
if [ 1 -gt 0 ] | |
then | |
echo "my_output=true" >> "$GITHUB_OUTPUT" | |
echo "That is correct" | |
else | |
echo "my_output=false" >> "$GITHUB_OUTPUT" | |
echo "That is wrong" | |
fi | |
echo "" | |
- name: 'print' | |
run: echo "${{ steps.job1.outputs.my_output }}" | |
job2: | |
runs-on: ubuntu-latest | |
needs: job1 | |
steps: | |
- name: Triggered only if value is true (using if) | |
if: ${{ needs.job1.outputs.my_output }} | |
run: | | |
echo "The condition 1 was met!" | |
echo ${{ needs.job1.outputs.my_output }} | |
- name: Triggered only if value is true (using if ==) | |
if: ${{ needs.job1.outputs.my_output == 'true' }} | |
run: | | |
echo "The condition 2 was met!" | |
echo ${{ needs.job1.outputs.my_output }} | |
- name: Triggered only if value is false (using if ==) | |
if: ${{ needs.job1.outputs.my_output == 'false' }} | |
run: | | |
echo "The condition was not met!" | |
echo ${{ needs.job1.outputs.my_output }} |