08 - Outputs Workflow #950
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: 08 - Outputs Workflow | |
on: | |
schedule: | |
- cron: "0 6 * * MON-FRI" # Runs at 6:00 UTC | |
workflow_dispatch: | |
jobs: | |
job1: | |
runs-on: ubuntu-latest | |
# Map a step output to a job output | |
outputs: | |
output1: ${{ steps.step1.outputs.test }} | |
output2: ${{ steps.step2.outputs.test }} | |
steps: | |
- id: step1 | |
run: echo "::set-output name=test::hello" | |
- id: step2 | |
run: echo "::set-output name=test::world" | |
job2: | |
runs-on: ubuntu-latest | |
# Wait from the job1 to be completed before starting job2 | |
needs: job1 | |
steps: | |
- run: echo ${{needs.job1.outputs.output1}} ${{needs.job1.outputs.output2}} | |
job3: | |
runs-on: ubuntu-latest | |
needs: [job1, job2] | |
steps: | |
- run: echo "Goodbye" | |
job4: | |
runs-on: ubuntu-latest | |
steps: | |
- name: step-1 | |
id: xyz | |
run: echo "::set-output name=ip-address::$(curl -s ifconfig.me)" | |
- name: step-2 | |
run: echo "${{ steps.xyz.outputs.ip-address }}" | |
- name: step-3 | |
run: | | |
echo '{ | |
"ip-address": "${{ steps.xyz.outputs.ip-address }}" | |
}' | |
job5: | |
runs-on: ubuntu-latest | |
steps: | |
- name: step-1 | |
id: xyz | |
run: echo "::set-output name=acc::$(echo $RANDOM)" | |
- name: step-2 | |
if: steps.xyz.outputs.acc < 1 | |
run: | | |
echo "Number lower than 1" | |
echo "${{ steps.xyz.outputs.acc }}" | |
- name: step-3 | |
if: steps.xyz.outputs.acc > 1 | |
run: | | |
echo "Number higher than 1" | |
echo "${{ steps.xyz.outputs.acc }}" | |
# job6: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: step-1 | |
# id: wxyz | |
# uses: actions/create-release@v1 | |
# with: | |
# tag_name: 0.0.1 | |
# release_name: 0.0.1 | |
# body: "This is release 0.0.1" | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# - name: step-2 | |
# run: echo "${{ steps.wxyz.outputs.html_url }}" | |