generated from ps-actions-sandbox/ActionsFundamentals
-
Notifications
You must be signed in to change notification settings - Fork 1
188 lines (156 loc) · 4.81 KB
/
starter.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: Starter Workflow
on:
# Webhook events
push:
branches:
- 'release/*'
paths-ignore:
- '.github/workflows'
issues:
types: [opened, reopened]
# Scheduled events
schedule:
# - cron: '*/15 * * * *'
# - cron: '0 9-17 * * *'
- cron: '11 11 * * 5'
# Manual events
workflow_dispatch:
inputs:
homedrive:
description: 'The home drive on the machine'
required: true
default: '/home'
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
run_matrix:
description: 'Run the matrix jobs'
required: true
type: boolean
environment:
description: 'Environment to run tests against'
type: environment
required: true
# Trigger using the API
repository_dispatch:
types: [customEvent]
# Call for example using GitHub CLI:
# $ gh api -X POST -H "Accept: application/vnd.github.v3+json" \
# /repos/wulfland/AccelerateDevOps/dispatches \
# -f event_type=customEvent
env:
MY_ENV: A value availbale as environment variable
permissions:
contents: read
issues: write
jobs:
job_1:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was triggered by a ${{ github['event_name'] }} event."
- run: echo "🏠 drive is `${{ github.event.inputs.homedrive }}`."
- run: echo "🎯 environment is `${{ github.event.inputs.environment }}`."
- run: echo "📖 log level is `${{ github.event.inputs.logLevel }}`."
- run: echo "➿ Run the matrix? `${{ github.event.inputs.run_matrix }}`."
- name: Get OS information
run: |
import platform
print(platform.platform())
shell: python
- uses: actions/checkout@v4
#- uses: actions/[email protected]
#- uses: actions/checkout@v4
#- uses: actions/checkout@main
- name: Run a docker containers as an action
uses: docker://alpine:3.8
- uses: docker://ghcr.io/wulfland/container-demo:latest
- name: Display documentation
run: tree
working-directory: docs
job_2:
runs-on: ubuntu-latest
needs: job_1
steps:
- run: echo "Status ${{ job.status }}"
job_3:
runs-on: ubuntu-latest
needs: job_1
steps:
- run: echo "Services ${{ job.services }}"
job_4:
runs-on: ubuntu-latest
needs: [job_2, job_3]
steps:
- run: echo "Status ${{ job.status }}"
matrix_job:
name: Matrix
runs-on: ${{ matrix.runner }}
if: github.event.inputs.run_matrix == 'true'
strategy:
matrix:
runner: [ubuntu-18.04, ubuntu-20.04]
node: [10,12]
fail-fast: true
max-parallel: 4
steps:
- run: echo "${{ matrix.runner }}"
- run: echo "${{ matrix.node }}"
context_job:
runs-on: ubuntu-latest
name: Context
steps:
- name: Dump GitHub context
run: echo '${{ toJSON(github) }}'
- name: Dump job context
run: echo '${{ toJSON(job) }}'
- name: Dump runner context
run: echo '${{ toJSON(runner) }}'
- name: Dump env context
run: echo '${{ toJSON(env) }}'
expression_job:
runs-on: ubuntu-latest
name: Expressions
if: ${{ github.ref == 'refs/heads/main' && github.event.inputs.logLevel == 'debug' }}
steps:
- run: echo "Only run if triggered by main branch..."
if: contains(github.ref, 'main')
- run: |
echo "Fail depending on parameter"
return 1
if: github.event.inputs.run_matrix == 'true'
- run: echo "Run always"
if: always()
- run: echo "Run only on success"
if: success()
- run: echo "Run only on failure"
if: failure()
workflow_commands:
runs-on: ubuntu-latest
name: Workflow Commands
steps:
- name: Set time
run: echo 'my_time=$(date)' >> $GITHUB_OUTPUT
id: set-time
- name: Output time
run: echo "It was ${{ steps.set-time.outputs.my_time }} in the previous step."
- name: Writing to the workflow log
run: |
echo "Writing to the workflow log"
echo "::group::Writing to the log"
echo "::notice file=starter.yml,line=169,col=19,endColumn=22::Writing a notice"
echo "::warning file=starter.yml,line=171,col=19,endColumn=22::Writing a warning"
echo "::endgroup::"
label_issues:
runs-on: ubuntu-latest
if: github.event_name == 'issues'
steps:
- uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90
with:
add-labels: documentation
repo-token: ${{ secrets.GITHUB_TOKEN }}