-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshell.yml
More file actions
114 lines (99 loc) · 2.41 KB
/
shell.yml
File metadata and controls
114 lines (99 loc) · 2.41 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Shell Action Examples
description: Demonstrates shell action usage with various configurations
vars:
ci: "{{CI}}"
project_dir: "/tmp/probe-shell-demo"
build_timeout: "30s"
jobs:
- name: Basic Shell Commands
steps:
- name: Simple echo
uses: shell
with:
cmd: "echo 'Hello from Shell Action!'"
test: res.code == 0
- name: Environment variable usage
uses: shell
with:
cmd: "echo 'Project directory: $PROJECT_DIR'"
env:
PROJECT_DIR: "{{vars.project_dir}}"
test: res.code == 0
- name: Working directory example
uses: shell
with:
cmd: |
mkdir -p /tmp/probe-workdir-test
cd /tmp/probe-workdir-test
pwd
ls -la
cd -
rm -rf /tmp/probe-workdir-test
workdir: "/tmp"
test: res.code == 0
- name: Advanced Shell Usage
steps:
- name: Custom shell (bash)
uses: shell
with:
cmd: "echo 'Running in: $0'"
shell: "/bin/bash"
test: res.code == 0
- name: Command with timeout
uses: shell
with:
cmd: "sleep 1 && echo 'Task completed'"
timeout: "{{vars.build_timeout}}"
test: res.code == 0
- name: Error handling example
uses: shell
with:
cmd: "echo 'This will fail' && exit 1"
test: res.code == 1
- name: Command not found (exit code 127)
uses: shell
with:
cmd: "nonexistent_command"
test: res.code == 127
- name: Permission denied simulation (exit code 126)
uses: shell
with:
cmd: "echo 'exit 126' | sh"
test: res.code == 126
- name: Output Capture Examples
steps:
- name: Capture stdout
id: output_test
uses: shell
with:
cmd: "echo 'Success message'"
outputs:
message: res.stdout
test: res.code == 0
- name: Capture stderr
uses: shell
with:
cmd: "echo 'Warning message' >&2"
test: res.code == 0
- name: Use previous output
uses: shell
with:
cmd: "echo 'Previous output was: {{outputs.output_test.message}}'"
test: res.code == 0
- name: Practical Examples
steps:
- name: System information
uses: shell
with:
cmd: "uname -a"
test: res.code == 0
- name: File operations
uses: shell
with:
cmd: "mkdir -p /tmp/test && echo 'test content' > /tmp/test/file.txt && cat /tmp/test/file.txt"
test: res.code == 0
- name: Cleanup
uses: shell
with:
cmd: "rm -rf /tmp/test"
test: res.code == 0