Skip to content

Commit b8615ec

Browse files
Fixed curly blackets
1 parent 787cd50 commit b8615ec

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

_posts/2022-05-10-Github-Actions.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,20 @@ Setup hierarchy:
6262
6363
### Security policy
6464
65+
{% raw %}
6566
- **DO NOT** use self-hosted runners for a public repository
6667
- Risk: allow arbitrary code execution on your machine.
6768
- Configurable requirement for PR: e.g. approval from someone with write access.
68-
- Secrets from settings: `$\{\{ secrets.PASSWORD \}\}`
69+
- Secrets from settings: `${{ secrets.PASSWORD }}`
6970
- For self-hosted runners, store on the machine instead.
71+
{% endraw %}
7072

7173
## Techniques
7274
### Expressions
7375

74-
Use `$\{\{ <expression> \}\}` to pragmatically generate configuration.
76+
{% raw %}
77+
Use `${{ <expression> }}` to pragmatically generate configuration.
78+
{% endraw %}
7579

7680
- Literals: null, true, 42, 'spam'
7781
- Operators: matrix.device == 'cpu'
@@ -86,14 +90,16 @@ Use `$\{\{ <expression> \}\}` to pragmatically generate configuration.
8690

8791
### Contexts
8892

89-
Variables of workflow information, `$\{\{ <context> \}\}`
93+
{% raw %}
94+
Variables of workflow information, `${{ <context> }}`
9095

9196
Conditional execution example:
9297

9398
```yaml
94-
- run: mkdir $\{\{ github.job \}\}
95-
if: $\{\{ github.ref == 'refs/heads/main' \}\}
99+
- run: mkdir ${{ github.job }}
100+
if: ${{ github.ref == 'refs/heads/main' }}
96101
```
102+
{% endraw %}
97103

98104
### Triggering a workflow
99105

@@ -112,15 +118,17 @@ branches:
112118

113119
Jobs run in parallel and may be assigned to different runners.
114120

121+
{% raw %}
115122
```yaml
116123
jobs:
117124
job1:
118125
job2:
119126
needs: job1
120127
job3:
121-
if: $\{\{ always() \}\}
128+
if: ${{ always() }}
122129
needs: [job1, job2]
123130
```
131+
{% endraw %}
124132

125133
[https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
126134

@@ -139,8 +147,9 @@ When registering runners, set corresponding labels.
139147

140148
Procedurally generate build configuration combinations.
141149

150+
{% raw %}
142151
```yaml
143-
runs-on: $\{\{ matrix.os \}\}
152+
runs-on: ${{ matrix.os }}
144153
strategy:
145154
matrix:
146155
node: [8, 10, 12, 14]
@@ -152,6 +161,7 @@ strategy:
152161
- os: macos-latest
153162
node: 8
154163
```
164+
{% endraw %}
155165

156166
[https://docs.github.com/en/actions/using-jobs/using-a-build-matrix-for-your-jobs](https://docs.github.com/en/actions/using-jobs/using-a-build-matrix-for-your-jobs
157167
)
@@ -186,6 +196,7 @@ CI=true
186196

187197
### Setup environment variables
188198

199+
{% raw %}
189200
```yaml
190201
env:
191202
DAY_OF_WEEK: Monday
@@ -195,11 +206,12 @@ jobs:
195206
env:
196207
Greeting: Hello
197208
steps:
198-
- if: $\{\{ env.DAY_OF_WEEK == 'Monday' \}\}
209+
- if: ${{ env.DAY_OF_WEEK == 'Monday' }}
199210
run: echo ”$Greeting $First_Name. Today is $DAY_OF_WEEK!”
200211
env:
201212
First_Name: Mona
202213
```
214+
{% endraw %}
203215

204216
[https://docs.github.com/en/actions/learn-github-actions/environment-variables](https://docs.github.com/en/actions/learn-github-actions/environment-variables)
205217

@@ -255,10 +267,12 @@ For hosted artifact storage:
255267

256268
Our solution for hosted runners:
257269

270+
{% raw %}
258271
```yaml
259-
upload-artifacts ”Result tarballs” $\{\{ github.job \}\}
272+
upload-artifacts ”Result tarballs” ${{ github.job }}
260273
result '*.tar.gz'
261274
```
275+
{% endraw %}
262276

263277
- Each file is stored to a s3 bucket.
264278
- A public link is added to the log.
@@ -295,30 +309,36 @@ However,
295309
- No anchors and aliases (&anchor and *anchor)
296310
- Context expansion may cause syntax errors
297311

312+
{% raw %}
298313
```yaml
299314
strategy:
300315
matrix:
301316
device: [cpu, gpu]
302-
runs-on: [self-hosted, $\{\{ matrix.device \}\}]
317+
runs-on: [self-hosted, ${{ matrix.device }}]
303318
```
319+
{% endraw %}
304320

305321
but this works:
306322

323+
{% raw %}
307324
```yaml
308325
runs-on:
309326
- self-hosted
310-
- $\{\{ matrix.device }}
327+
- ${{ matrix.device }}
311328
```
329+
{% endraw %}
312330

313331
### Context availability
314332

333+
{% raw %}
315334
```yaml
316335
test-context:
317336
steps:
318-
- name: $\{\{ github.job \}\}
337+
- name: ${{ github.job }}
319338
run: ...
320-
- run: echo $\{\{ github.job \}\}
339+
- run: echo ${{ github.job }}
321340
```
341+
{% endraw %}
322342

323343
github.job: job id (i.e. test-context)
324344

0 commit comments

Comments
 (0)