-
Notifications
You must be signed in to change notification settings - Fork 102
75 lines (60 loc) · 2.03 KB
/
workflow-tester63.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
name: Test 63 # Related to https://stackoverflow.com/questions/74117204/how-to-generate-a-new-string-by-combine-github-action-workflow-variables
on:
#push:
workflow_dispatch:
jobs:
job1:
runs-on: ubuntu-latest
steps:
- name: Check context var
run: |
echo '${{ github.event.head_commit.message }}'
echo '${{ github.sha }}'
# echo MESSAGE_SHA='${{ github.event.head_commit.message }}'-'${{ github.sha }}' >> $GITHUB_ENV
- name: Setup env var
run: |
MESSAGE=$(cat << EOF
'${{ github.event.head_commit.message }}'
-'${{ github.sha }}'
EOF
)
echo MESSAGE_SHA=$MESSAGE >> $GITHUB_ENV
- name: Check env var
run: |
echo ${{ env.MESSAGE_SHA }}
# Testing same implementation for OUTPUT
- name: Setup output var
id: test1
run: |
MESSAGE=$(cat << EOF
'${{ github.event.head_commit.message }}'
-'${{ github.sha }}'
EOF
)
echo MESSAGE_SHA=$MESSAGE >> $GITHUB_OUTPUT
- name: Check output var
run: |
echo ${{steps.test1.outputs.MESSAGE_SHA}}
# Testing other syntaxes
- name: Setup output var2
id: test2
run: echo "TEST2=first line\n second line\n third line" >> $GITHUB_OUTPUT
- name: Check output var2
run: |
echo ${{steps.test2.outputs.TEST2}} #Will keep the n from the \n
echo -e "${{steps.test2.outputs.TEST2}}" #Will break the line from the \n
- name: Setup output var3
id: test3
run: |
echo "TEST3=first line \
second line \
third line" >> $GITHUB_OUTPUT
- name: Check output var3
run: echo ${{steps.test3.outputs.TEST3}}
- name: Setup output var4
id: test4
continue-on-error: true
run: echo TEST4=$(echo -e "first line\n second line\n third line") >> $GITHUB_OUTPUT
- name: Check output var4
run: |
echo ${{steps.test4.outputs.TEST4}}