Skip to content

Commit 590ed56

Browse files
Copilotneilime
andcommitted
Update documentation for container options support
Co-authored-by: neilime <[email protected]>
1 parent e4455fe commit 590ed56

File tree

1 file changed

+92
-2
lines changed

1 file changed

+92
-2
lines changed

.github/workflows/continuous-integration.md

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,29 @@ jobs:
126126
# Default: `.`
127127
working-directory: .
128128

129-
# Docker container image to run CI steps in. When specified, steps will execute inside this container instead of checking out code. The container should have the project code and dependencies pre-installed.
129+
# Container configuration to run CI steps in.
130+
# Accepts either a string (container image name) or a JSON object with container options.
131+
#
132+
# String format (simple):
133+
# container: "node:18"
134+
#
135+
# JSON object format (advanced):
136+
# container: |
137+
# {
138+
# "image": "node:18",
139+
# "env": {
140+
# "NODE_ENV": "production"
141+
# },
142+
# "ports": [8080],
143+
# "volumes": ["/tmp:/tmp"],
144+
# "options": "--cpus 2"
145+
# }
146+
#
147+
# All properties from GitHub's container specification are supported except credentials (use secrets instead).
148+
# See https://docs.github.com/en/actions/how-tos/write-workflows/choose-where-workflows-run/run-jobs-in-a-container
149+
#
150+
# When specified, steps will execute inside this container instead of checking out code.
151+
# The container should have the project code and dependencies pre-installed.
130152
container: ""
131153
````
132154

@@ -162,10 +184,39 @@ jobs:
162184
| | Set to `null` or empty to disable. | | | |
163185
| | Accepts a JSON object for test options. See [test action](../actions/test/README.md). | | | |
164186
| **`working-directory`** | Working directory where the dependencies are installed. | **false** | **string** | `.` |
165-
| **`container`** | Docker container image to run CI steps in. When specified, steps will execute inside this container instead of checking out code. The container should have the project code and dependencies pre-installed. | **false** | **string** | - |
187+
| **`container`** | Container configuration to run CI steps in. Accepts string or JSON object. See Container Configuration below | **false** | **string** | - |
166188

167189
<!-- inputs:end -->
168190

191+
### Container Configuration
192+
193+
The `container` input accepts either:
194+
195+
**Simple string format** (image name only):
196+
197+
```yaml
198+
container: "node:18"
199+
```
200+
201+
**Advanced JSON format** (with container options):
202+
203+
```yaml
204+
container: |
205+
{
206+
"image": "node:18",
207+
"env": {
208+
"NODE_ENV": "production"
209+
},
210+
"ports": [8080],
211+
"volumes": ["/tmp:/tmp"],
212+
"options": "--cpus 2"
213+
}
214+
```
215+
216+
All properties from [GitHub's container specification](https://docs.github.com/en/actions/how-tos/write-workflows/choose-where-workflows-run/run-jobs-in-a-container) are supported except `credentials` (use secrets instead).
217+
218+
When specified, steps will execute inside this container instead of checking out code. The container should have the project code and dependencies pre-installed.
219+
169220
<!-- secrets:start -->
170221

171222
## Secrets
@@ -289,6 +340,45 @@ jobs:
289340
test: true
290341
```
291342

343+
### Continuous Integration with Advanced Container Options
344+
345+
This example shows how to use advanced container options like environment variables, ports, volumes, and additional Docker options.
346+
347+
```yaml
348+
name: Continuous Integration - Advanced Container Options
349+
350+
on:
351+
push:
352+
branches: [main]
353+
354+
jobs:
355+
continuous-integration:
356+
uses: hoverkraft-tech/ci-github-nodejs/.github/workflows/continuous-integration.yml@32a69b7b8fd5f7ab7bf656e7e88aa90ad235cf8d # 0.18.0
357+
permissions:
358+
id-token: write
359+
security-events: write
360+
contents: read
361+
with:
362+
container: |
363+
{
364+
"image": "node:18-alpine",
365+
"env": {
366+
"NODE_ENV": "production",
367+
"CI": "true"
368+
},
369+
"ports": [3000, 8080],
370+
"volumes": ["/tmp:/tmp", "/cache:/cache"],
371+
"options": "--cpus 2 --memory 4g"
372+
}
373+
# When using container mode, code-ql and dependency-review are typically disabled
374+
# as they require repository checkout
375+
code-ql: ""
376+
dependency-review: false
377+
build: "build"
378+
lint: true
379+
test: true
380+
```
381+
292382
<!-- examples:end -->
293383

294384
<!-- contributing:start -->

0 commit comments

Comments
 (0)