Skip to content

Commit 258d1dc

Browse files
committed
feat: add expression functions demo workflow with various string checks and JSON parsing
1 parent 7a94910 commit 258d1dc

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Expression Functions Demo
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
issues:
8+
types: [opened, labeled]
9+
10+
jobs:
11+
expression-functions:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check if string contains substring
15+
if: contains('Hello world', 'llo')
16+
run: echo "The string contains the substring."
17+
18+
- name: Check if string starts with
19+
if: startsWith('Hello world', 'He')
20+
run: echo "The string starts with 'He'."
21+
22+
- name: Check if string ends with
23+
if: endsWith('Hello world', 'ld')
24+
run: echo "The string ends with 'ld'."
25+
26+
- name: Format and echo string
27+
run: echo ${{ format('Hello {0} {1} {2}', 'Mona', 'the', 'Octocat') }}
28+
29+
- name: Join issue labels
30+
if: github.event_name == 'issues'
31+
run: "echo 'Issue labels: ${{ join(github.event.issue.labels.*.name, ", ") }}'"
32+
33+
- name: Convert job context to JSON
34+
run: "echo 'Job context in JSON: ${{ toJSON(github.job) }}'"
35+
36+
- name: Parse JSON string
37+
run: echo 'Parsed JSON: ${{ fromJSON("{\"hello\":\"world\"}").hello }}'
38+
39+
- name: Hash files
40+
run: echo 'Hash of files: ${{ hashFiles("**/package-lock.json", "**/Gemfile.lock") }}'
41+
42+
- name: The job has succeeded
43+
if: success()
44+
run: echo "The job succeeded."
45+
46+
- name: The job has failed
47+
if: failure()
48+
run: echo "The job failed."

0 commit comments

Comments
 (0)