1
+ name : Expression Functions Demo
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+
8
+ jobs :
9
+ expression-functions :
10
+ runs-on : ubuntu-latest
11
+ steps :
12
+ - name : Check if string contains substring
13
+ if : contains('Hello world', 'llo')
14
+ run : echo "The string contains the substring."
15
+ - name : Check if string starts with
16
+ if : startsWith('Hello world', 'He')
17
+ run : echo "The string starts with 'He'."
18
+ - name : Check if string ends with
19
+ if : endsWith('Hello world', 'ld')
20
+ run : echo "The string ends with 'ld'."
21
+ - name : Format and echo string
22
+ run : echo ${{ format('Hello {0} {1} {2}', 'Mona', 'the', 'Octocat') }}
23
+ - name : Join issue labels
24
+ if : github.event_name == 'issues'
25
+ run : echo "Issue labels: ${{ join(github.event.issue.labels.*.name, ', ') }}"
26
+ - name : Convert job context to JSON
27
+ run : echo "Job context in JSON: ${{ toJSON(github.job) }}"
28
+ - name : Parse JSON string
29
+ run : echo "Parsed JSON: ${{ fromJSON('{"hello":"world"}').hello }}"
30
+ - name : Hash files
31
+ run : echo "Hash of files: ${{ hashFiles('**/package-lock.json', '**/Gemfile.lock') }}
32
+ - name : The job has succeeded
33
+ if : ${{ success() }}
34
+ - name : The job has failed
35
+ if : ${{ failure() }}
0 commit comments