-
Notifications
You must be signed in to change notification settings - Fork 102
89 lines (75 loc) · 2.2 KB
/
08-outputs-workflow2.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: 08 - Outputs Workflow 2
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 "test=hello" >> $GITHUB_OUTPUT
- id: step2
run: echo "test=world" >> $GITHUB_OUTPUT
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 "ip-address=$(curl -s ifconfig.me)" >> $GITHUB_OUTPUT
- 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 "acc=$(echo $RANDOM)" >> $GITHUB_OUTPUT
- 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: Setup multiline output
id: test
run: |
echo "TEST=first line \
second line \
third line" >> $GITHUB_OUTPUT
- name: Check multiline output
run: echo ${{steps.test.outputs.TEST}}
- name: Setup multiline output 2
id: test2
run: echo "TEST=first line\n second line\n third line" >> $GITHUB_OUTPUT
- name: Check multiline output 2
run: |
echo ${{steps.test2.outputs.TEST}} # Will keep the n from the \n
echo -e "${{steps.test2.outputs.TEST}}" # Will break the line from the \n