-
-
Notifications
You must be signed in to change notification settings - Fork 3
70 lines (63 loc) · 2.27 KB
/
expressions.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
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions
name: expressions
on: push
jobs:
expressions:
runs-on: ubuntu-latest
steps:
- name: Literals
run: |
echo $myNull
echo $myBoolean
echo $myIntegerNumber
echo $myFloatNumber
echo $myHexNumber
echo $myExponentialNumber
echo $myString
echo $myStringInBraces
env:
myNull: ${{ null }}
myBoolean: ${{ false }}
myIntegerNumber: ${{ 711 }}
myFloatNumber: ${{ -9.2 }}
myHexNumber: ${{ 0xff }}
myExponentialNumber: ${{ -2.99e-2 }}
myString: Mona the Octocat
myStringInBraces: ${{ 'It''s open source!' }}
- name: Operators
run: echo $MY_ENV_VAR
env:
MY_ENV_VAR: ${{ github.ref == 'refs/heads/master' && 'value_for_main_branch' || 'value_for_other_branches' }}
- name: Functions
run: |
echo $contains
echo $startsWith
echo $endsWith
echo $format
echo $formatEscapingBraces
echo $join
echo $toJSON
echo $fromJSON
echo $hashFiles
env:
contains: ${{ contains('Hello world', 'llo') }} # true
startsWith: ${{ startsWith('Hello world', 'He') }} # true
endsWith: ${{ endsWith('Hello world', 'ld') }} # true
format: ${{ format('Hello {0} {1} {2}', 'Mona', 'the', 'Octocat') }} # 'Hello Mona the Octocat'
formatEscapingBraces: ${{ format('{{Hello {0} {1} {2}!}}', 'Mona', 'the', 'Octocat') }} # '{Hello Mona the Octocat!}'
join: ${{ join(github.event.issue.labels.*.name, ', ') }} # 'bug, help wanted'
toJSON: ${{ toJSON(job) }} # { "status": "success" }
fromJSON: ${{ contains(fromJSON('["push", "pull_request"]'), github.event_name) }} # true
hashFiles: ${{ hashFiles('**/package-lock.json') }}
- name: success
if: success()
run: echo success
- name: always
if: always()
run: echo always
- name: cancelled
if: cancelled()
run: echo cancelled
- name: failure
if: failure()
run: echo failure