Skip to content

Commit d082433

Browse files
Copilotneilime
andcommitted
docs: add yml syntax highlighting to code block
Co-authored-by: neilime <[email protected]> Signed-off-by: Emilien Escalle <[email protected]>
1 parent 893f457 commit d082433

File tree

2 files changed

+73
-35
lines changed

2 files changed

+73
-35
lines changed

.github/workflows/__test-workflow-continuous-integration.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ jobs:
128128
"NODE_ENV": "test",
129129
"CI": "true"
130130
},
131-
"options": "--cpus 1"
131+
"options": "--cpus 1",
132+
"credentials": {
133+
"username": "${{ github.actor }}"
134+
}
132135
}
133136
working-directory: /usr/src/app/
134137
build: |
@@ -137,6 +140,8 @@ jobs:
137140
}
138141
test: |
139142
{"coverage": "codecov"}
143+
secrets:
144+
container-password: ${{ secrets.GITHUB_TOKEN }}
140145

141146
assert-with-container-advanced:
142147
name: Assert - Ensure build artifact has been uploaded (with container advanced)

.github/workflows/continuous-integration.yml

Lines changed: 67 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ on:
8888
Accepts either a string (container image name) or a JSON object with container options.
8989
9090
String format (simple):
91-
```
91+
```yml
9292
container: "node:18"
9393
```
9494
@@ -123,6 +123,12 @@ on:
123123
SECRET_EXAMPLE=$\{{ secrets.SECRET_EXAMPLE }}
124124
```
125125
required: false
126+
container-password:
127+
description: |
128+
Password for container registry authentication, if required.
129+
Used when the container image is hosted in a private registry.
130+
See https://docs.github.com/en/actions/how-tos/write-workflows/choose-where-workflows-run/run-jobs-in-a-container#defining-credentials-for-a-container-registry.
131+
required: false
126132
outputs:
127133
build-artifact-id:
128134
description: "ID of the build artifact) uploaded during the build step."
@@ -131,13 +137,14 @@ on:
131137
permissions: {}
132138

133139
jobs:
134-
parse-container:
135-
name: 📦 Parse Container Configuration
136-
if: inputs.container != ''
140+
prepare:
141+
name: 📦 Prepare configuration
137142
runs-on: ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
138143
permissions: {}
139144
outputs:
140-
config: ${{ steps.parse.outputs.config }}
145+
container-image: ${{ steps.parse.outputs.container-image }}
146+
container-options: ${{ steps.parse.outputs.container-options }}
147+
container-username: ${{ steps.parse.outputs.container-username }}
141148
steps:
142149
- id: parse
143150
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
@@ -150,7 +157,7 @@ jobs:
150157
// Check if input is a JSON object or a simple string
151158
const isJson = containerInput.startsWith('{');
152159
153-
let config = {
160+
let container = {
154161
image: '',
155162
options: '--user root:root'
156163
};
@@ -160,27 +167,35 @@ jobs:
160167
const container = JSON.parse(containerInput);
161168
162169
// Set image
163-
config.image = container.image || '';
170+
container.image = container.image || '';
164171
165172
// Add env if provided
166173
if (container.env && Object.keys(container.env).length > 0) {
167-
config.env = container.env;
174+
container.env = container.env;
168175
}
169176
170177
// Merge user options with default --user root:root
171178
if (container.options) {
172-
config.options = `${config.options} ${container.options}`;
179+
container.options = `${container.options} ${container.options}`;
173180
}
174181
} catch (error) {
175182
core.setFailed(`Failed to parse container input as JSON: ${error.message}`);
176183
return;
177184
}
178185
} else {
179186
// Simple string format - just the image name
180-
config.image = containerInput;
187+
container.image = containerInput;
181188
}
182189
183-
core.setOutput('config', JSON.stringify(config));
190+
if (container.image) {
191+
core.setOutput('container-image', container.image);
192+
}
193+
if (container.options) {
194+
core.setOutput('container-options', JSON.stringify(container.options));
195+
}
196+
if (container.username) {
197+
core.setOutput('container-username', container.username);
198+
}
184199
185200
code-ql:
186201
name: 🛡️ CodeQL Analysis
@@ -208,9 +223,13 @@ jobs:
208223
setup:
209224
name: ⚙️ Setup
210225
runs-on: ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
211-
container: ${{ inputs.container != '' && fromJSON(needs.parse-container.outputs.config) || null }}
212-
needs: parse-container
213-
if: ${{ always() && !cancelled() && !failure() }}
226+
needs: prepare
227+
container:
228+
image: ${{ needs.prepare.outputs.container-image || '' }}
229+
options: ${{ needs.prepare.outputs.container-options && fromJSON(needs.prepare.outputs.container-options) || null }}
230+
credentials:
231+
username: ${{ needs.prepare.outputs.container-username || null }}
232+
password: ${{ secrets.container-password || null }}
214233
permissions:
215234
contents: read
216235
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
@@ -220,7 +239,7 @@ jobs:
220239
build-commands: ${{ steps.build-variables.outputs.commands }}
221240
build-artifact: ${{ steps.build-variables.outputs.artifact }}
222241
steps:
223-
- if: inputs.container == ''
242+
- if: needs.prepare.outputs.container-image == null
224243
uses: hoverkraft-tech/ci-github-common/actions/checkout@753288393de1f3d92f687a6761d236ca800f5306 # 0.28.1
225244

226245
- id: build-variables
@@ -324,22 +343,26 @@ jobs:
324343
325344
lint:
326345
name: 👕 Lint
327-
if: inputs.checks == true && inputs.lint && always() && !cancelled() && !failure()
328-
runs-on: ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
329-
container: ${{ inputs.container != '' && fromJSON(needs.parse-container.outputs.config) || null }}
346+
if: inputs.checks == true && inputs.lint
330347
needs:
331-
- parse-container
348+
- prepare
332349
- setup
350+
runs-on: ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
351+
container:
352+
image: ${{ needs.prepare.outputs.container-image || null }}
353+
options: ${{ needs.prepare.outputs.container-options || null }}
354+
credentials:
355+
username: ${{ needs.prepare.outputs.container-username || null }}
356+
password: ${{ secrets.container-password || null }}
333357
# jscpd:ignore-start
334358
permissions:
335359
contents: read
336360
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
337361
id-token: write
338362
steps:
339363
- uses: hoverkraft-tech/ci-github-common/actions/checkout@753288393de1f3d92f687a6761d236ca800f5306 # 0.28.1
340-
if: inputs.container == ''
364+
if: needs.prepare.outputs.container-image == null
341365

342-
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
343366
- id: oidc
344367
uses: ChristopherHX/oidc@73eee1ff03fdfce10eda179f617131532209edbd # v3
345368
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -375,16 +398,21 @@ jobs:
375398
- uses: ./self-workflow/actions/lint
376399
with:
377400
working-directory: ${{ inputs.working-directory }}
378-
container: ${{ inputs.container != '' }}
401+
container: ${{ needs.prepare.outputs.container-image && 'true' || 'false' }}
379402

380403
build:
381404
name: 🏗️ Build
382-
if: inputs.checks == true && always() && !cancelled() && !failure()
405+
if: inputs.checks == true
383406
runs-on: ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
407+
container:
408+
image: ${{ needs.prepare.outputs.container-image || null }}
409+
options: ${{ needs.prepare.outputs.container-options || null }}
410+
credentials:
411+
username: ${{ needs.prepare.outputs.container-username || null }}
412+
password: ${{ secrets.container-password || null }}
384413
# jscpd:ignore-start
385-
container: ${{ inputs.container != '' && fromJSON(needs.parse-container.outputs.config) || null }}
386414
needs:
387-
- parse-container
415+
- prepare
388416
- setup
389417
permissions:
390418
contents: read
@@ -394,7 +422,7 @@ jobs:
394422
artifact-id: ${{ steps.build.outputs.artifact-id }}
395423
steps:
396424
- uses: hoverkraft-tech/ci-github-common/actions/checkout@753288393de1f3d92f687a6761d236ca800f5306 # 0.28.1
397-
if: needs.setup.outputs.build-commands && inputs.container == ''
425+
if: needs.setup.outputs.build-commands && needs.prepare.outputs.container-image == null
398426

399427
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
400428
- id: oidc
@@ -422,15 +450,20 @@ jobs:
422450
build-env: ${{ needs.setup.outputs.build-env }}
423451
build-secrets: ${{ secrets.build-secrets }}
424452
build-artifact: ${{ needs.setup.outputs.build-artifact }}
425-
container: ${{ inputs.container != '' }}
453+
container: ${{ needs.prepare.outputs.container-image && 'true' || 'false' }}
426454

427455
test:
428456
name: 🧪 Test
429-
if: inputs.checks == true && inputs.test && always() && !cancelled() && !failure()
457+
if: inputs.checks == true && inputs.test
430458
runs-on: ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
431-
container: ${{ inputs.container != '' && fromJSON(needs.parse-container.outputs.config) || null }}
459+
container:
460+
image: ${{ needs.prepare.outputs.container-image || null }}
461+
options: ${{ needs.prepare.outputs.container-options || null }}
462+
credentials:
463+
username: ${{ needs.prepare.outputs.container-username || null }}
464+
password: ${{ secrets.container-password || null }}
432465
needs:
433-
- parse-container
466+
- prepare
434467
- setup
435468
- build
436469
permissions:
@@ -440,9 +473,9 @@ jobs:
440473
id-token: write
441474
steps:
442475
- uses: hoverkraft-tech/ci-github-common/actions/checkout@753288393de1f3d92f687a6761d236ca800f5306 # 0.28.1
443-
if: inputs.container == ''
476+
if: needs.prepare.outputs.container-image == null
444477

445-
- if: needs.build.outputs.artifact-id && inputs.container == ''
478+
- if: needs.build.outputs.artifact-id && needs.prepare.outputs.container-image == null
446479
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
447480
with:
448481
artifact-ids: ${{ needs.build.outputs.artifact-id }}
@@ -491,7 +524,7 @@ jobs:
491524
- uses: ./self-workflow/actions/test
492525
with:
493526
working-directory: ${{ inputs.working-directory }}
494-
container: ${{ inputs.container != '' }}
527+
container: ${{ needs.prepare.outputs.container-image && 'true' || 'false' }}
495528
coverage: ${{ steps.prepare-test-options.outputs.coverage }}
496-
coverage-files: ${{ steps.prepare-test-options.outputs['coverage-files'] }}
529+
coverage-files: ${{ steps.prepare-test-options.outputs.coverage-files }}
497530
github-token: ${{ github.token }}

0 commit comments

Comments
 (0)