Skip to content

Checking outputs

Checking outputs #7

name: Checking outputs
on:
workflow_dispatch:
jobs:
job1:
runs-on: ubuntu-latest
outputs:
result: $ {{ steps.set_value.outputs.my_output }}
steps:
- name: Set some value
id: set_value
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.set_value.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 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 was met!"
echo ${{ needs.job1.result.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 }}