Skip to content

Commit 0c21847

Browse files
ci(github): create expressions.yml
1 parent cf2d3bf commit 0c21847

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/expressions.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions
2+
name: expressions
3+
on: push
4+
5+
jobs:
6+
expressions:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Literals
10+
env:
11+
myNull: ${{ null }}
12+
myBoolean: ${{ false }}
13+
myIntegerNumber: ${{ 711 }}
14+
myFloatNumber: ${{ -9.2 }}
15+
myHexNumber: ${{ 0xff }}
16+
myExponentialNumber: ${{ -2.99e-2 }}
17+
myString: Mona the Octocat
18+
myStringInBraces: ${{ 'It''s open source!' }}
19+
20+
- name: Operators
21+
env:
22+
MY_ENV_VAR: ${{ github.ref == 'refs/heads/master' && 'value_for_main_branch' || 'value_for_other_branches' }}
23+
24+
- name: Functions
25+
if: contains(fromJSON('["push", "pull_request"]'), github.event_name) # true
26+
env:
27+
contains: contains('Hello world', 'llo') # true
28+
startsWith: startsWith('Hello world', 'He') # true
29+
endsWith: endsWith('Hello world', 'ld') # true
30+
format: format('Hello {0} {1} {2}', 'Mona', 'the', 'Octocat') # 'Hello Mona the Octocat'
31+
formatEscapingBraces: format('{{Hello {0} {1} {2}!}}', 'Mona', 'the', 'Octocat') # '{Hello Mona the Octocat!}'
32+
join: join(github.event.issue.labels.*.name, ', ') # 'bug, help wanted'
33+
toJSON: toJSON(job) # { "status": "success" }
34+
fromJSON: fromJSON('["push", "pull_request"]'
35+
hashFiles: hashFiles('**/package-lock.json')
36+
37+
- name: sucess
38+
if: ${{ success() }}
39+
40+
- name: always
41+
if: ${{ always() }}
42+
43+
- name: cancelled
44+
if: ${{ cancelled() }}
45+
46+
- name: failure
47+
if: ${{ failure() }}

0 commit comments

Comments
 (0)