Skip to content

Commit 13d8f21

Browse files
Merge pull request #139 from step-security/auto-cherry-pick
chore: Cherry-picked changes from upstream
2 parents fa65e2a + b6eb648 commit 13d8f21

12 files changed

Lines changed: 167 additions & 22 deletions

File tree

.github/workflows/actions_release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
tag:
77
description: "Tag for the release"
88
required: true
9+
script:
10+
description: "Specify a script to run after audit fix"
11+
required: false
12+
default: "yarn run all"
913

1014
permissions:
1115
contents: read
@@ -18,4 +22,5 @@ jobs:
1822
contents: write
1923
uses: step-security/reusable-workflows/.github/workflows/actions_release.yaml@v1
2024
with:
21-
tag: "${{ github.event.inputs.tag }}"
25+
tag: "${{ github.event.inputs.tag }}"
26+
script: "${{ github.event.inputs.tag }}"

.github/workflows/audit_package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
script:
1515
description: "Specify a script to run after audit fix"
1616
required: false
17-
default: "yarn build"
17+
default: "yarn run all"
1818

1919
schedule:
2020
- cron: "0 0 * * 1"
@@ -25,7 +25,7 @@ jobs:
2525
with:
2626
base_branch: ${{ inputs.base_branch || 'main' }}
2727
package_manager: "yarn"
28-
script: ${{ inputs.script || 'yarn build' }}
28+
script: ${{ inputs.script || 'yarn run all' }}
2929

3030
permissions:
3131
contents: write

.github/workflows/ci.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ on:
1818

1919
env:
2020
DOCKER_VERSION: v27.3.1
21+
DOCKER_BUILD_SUMMARY: false
2122

2223
jobs:
2324
main:
@@ -311,4 +312,32 @@ jobs:
311312
-
312313
name: List contexts
313314
run: |
314-
docker context ls
315+
docker context ls
316+
317+
tcp:
318+
runs-on: ${{ matrix.os }}
319+
strategy:
320+
fail-fast: false
321+
matrix:
322+
os:
323+
- ubuntu-latest
324+
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
325+
- macos-13
326+
- windows-latest
327+
steps:
328+
-
329+
name: Checkout
330+
uses: actions/checkout@v4
331+
-
332+
name: Set up Docker
333+
id: setup_docker
334+
uses: ./
335+
with:
336+
version: ${{ env.DOCKER_VERSION }}
337+
tcp-port: 2378
338+
-
339+
name: Check docker info through TCP
340+
run: |
341+
docker info
342+
env:
343+
DOCKER_HOST: ${{ steps.setup_docker.outputs.tcp }}

README.md

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ ___
3030
* [Define custom `limactl start` arguments (macOS)](#define-custom-limactl-start-arguments-macos)
3131
* [Customizing](#customizing)
3232
* [inputs](#inputs)
33+
* [inputs.version](#inputsversion)
3334
* [outputs](#outputs)
3435
* [Contributing](#contributing)
3536
* [License](#license)
@@ -50,7 +51,7 @@ jobs:
5051
steps:
5152
-
5253
name: Set up Docker
53-
uses: step-security/ghaction-setup-docker@v3
54+
uses: step-security/ghaction-setup-docker@v4
5455
```
5556
5657
### Daemon configuration
@@ -72,7 +73,7 @@ jobs:
7273
steps:
7374
-
7475
name: Set up Docker
75-
uses: step-security/ghaction-setup-docker@v3
76+
uses: step-security/ghaction-setup-docker@v4
7677
with:
7778
daemon-config: |
7879
{
@@ -100,7 +101,7 @@ jobs:
100101
steps:
101102
-
102103
name: Set up Docker
103-
uses: step-security/ghaction-setup-docker@v3
104+
uses: step-security/ghaction-setup-docker@v4
104105
env:
105106
LIMA_START_ARGS: --cpus 4 --memory 8
106107
```
@@ -113,20 +114,88 @@ The following inputs can be used as `step.with` keys
113114

114115
| Name | Type | Default | Description |
115116
|-----------------|--------|-----------------------|-----------------------------------------------------------------------------------------------------------------------------|
116-
| `version` | String | `latest` | Docker CE version (e.g., `v24.0.6`). |
117-
| `channel` | String | `stable` | Docker CE [channel](https://download.docker.com/linux/static/) (e.g, `stable`, `edge` or `test`). |
117+
| `version` | String | `latest` | Docker version to use. See [inputs.version](#inputs.version). |
118+
| `channel` | String | `stable` | Docker CE [channel](https://download.docker.com/linux/static/) (`stable` or `test`). Only applicable to `type=archive` |
118119
| `daemon-config` | String | | [Docker daemon JSON configuration](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file) |
120+
| `tcp-port` | Number | | TCP port to expose the Docker API locally |
119121
| `context` | String | `setup-docker-action` | Docker context name. |
120122
| `set-host` | Bool | `false` | Set `DOCKER_HOST` environment variable to docker socket path. |
121123
| `rootless` | Bool | `false` | Start daemon in rootless mode |
122124

125+
### inputs.version
126+
127+
By default, the latest stable version of Docker is fetched from download.docker.com.
128+
129+
You can specify a specific version number (e.g. `v27.4.0`).
130+
Which is a shorthand for the full comma separated value:
131+
132+
`type=archive,channel=stable,version=v27.4.0`
133+
134+
You can also use this full csv format instead.
135+
136+
Currently supported source types are:
137+
- `archive`
138+
- `image`
139+
140+
#### `type=archive`
141+
| Key | Default | Description |
142+
|-----------|------------|--------------------------------------------------------------------------------------|
143+
| `type` | `archive` | The source type of the Docker binaries. Possible values are `archive` and `image`. |
144+
| `channel` | `stable` | The download.docker.com channel (`stable` or `test`). |
145+
| `version` | `latest` | The Docker version to use. |
146+
147+
Examples:
148+
```yaml
149+
# last stable released version
150+
version: latest
151+
version: type=archive # same as above
152+
version: version=latest # same as above
153+
version: type=archive,version=latest # same as above
154+
```
155+
156+
```yaml
157+
# v27.3.0-rc.1 from test channel
158+
version: type=archive,version=27.3.0-rc.1,channel=test
159+
```
160+
161+
#### `type=image`
162+
163+
Other possible source type is `image` which will pull the Docker binaries from the `moby/moby-bin` and
164+
`dockereng/cli-bin` Docker Hub repositories.
165+
The advantage of using this source type is that these images are built by the Moby and Docker CI pipelines
166+
for each branch and PR, so you can use the `tag` input to install a specific version or branch (e.g. `master`).
167+
168+
| Key | Default | Description |
169+
|-----------|------------|--------------------------------------------------------------------------------------|
170+
| `tag` | `latest` | The image tag to use. |
171+
172+
See https://hub.docker.com/r/moby/moby-bin/tags and https://hub.docker.com/r/dockereng/cli-bin/tags for available tags.
173+
174+
Examples:
175+
```yaml
176+
# install last stable released version from bin images
177+
version: type=image
178+
version: type=image,tag=latest # same as above
179+
```
180+
181+
```yaml
182+
# a cutting-edge version from the `master` branch
183+
version: type=image,tag=master
184+
```
185+
186+
```yaml
187+
# install v27.4.0 from bin images
188+
version: type=image,tag=27.4.0
189+
```
190+
123191
### outputs
124192
125193
The following outputs are available
126194
127-
| Name | Type | Description |
128-
|--------|--------|--------------------|
129-
| `sock` | String | Docker socket path |
195+
| Name | Type | Description |
196+
|--------|--------|---------------------------------------|
197+
| `sock` | String | Docker socket path |
198+
| `tcp` | String | Docker TCP address if tcp-port is set |
130199

131200
## License
132201

__tests__/context.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,27 @@ describe('getInputs', () => {
185185
rootless: true,
186186
} as context.Inputs
187187
],
188+
[
189+
9,
190+
new Map<string, string>([
191+
['version', 'v24.0.8'],
192+
['tcp-port', '2378'],
193+
['set-host', 'false'],
194+
['rootless', 'false'],
195+
]),
196+
{
197+
source: {
198+
type: 'archive',
199+
version: 'v24.0.8',
200+
channel: 'stable'
201+
},
202+
context: '',
203+
daemonConfig: '',
204+
tcpPort: 2378,
205+
rootless: false,
206+
setHost: false
207+
} as context.Inputs
208+
],
188209
])(
189210
'[%d] given %p as inputs, returns %p',
190211
async (num: number, inputs: Map<string, string>, expected: context.Inputs) => {

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ inputs:
1616
daemon-config:
1717
description: 'Docker daemon JSON configuration'
1818
required: false
19+
tcp-port:
20+
description: 'TCP port to expose the Docker API locally'
21+
required: false
1922
context:
2023
description: 'Docker context name. (default setup-docker-action)'
2124
required: false
@@ -31,6 +34,8 @@ inputs:
3134
outputs:
3235
sock:
3336
description: "Docker socket path"
37+
tcp:
38+
description: "Docker TCP address if tcp-port is set"
3439

3540
runs:
3641
using: 'node20'

dist/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"license": "Apache-2.0",
2626
"dependencies": {
2727
"@actions/core": "^1.10.1",
28-
"@docker/actions-toolkit": "^0.46.0",
28+
"@docker/actions-toolkit": "^0.49.0",
2929
"uuid": "^10.0.0"
3030
},
3131
"devDependencies": {

src/context.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import * as core from '@actions/core';
2-
import {InstallSource} from '@docker/actions-toolkit/lib/docker/install';
32
import {parse} from 'csv-parse/sync';
43

4+
import {InstallSource} from '@docker/actions-toolkit/lib/docker/install';
5+
import {Util} from '@docker/actions-toolkit/lib/util';
6+
57
export interface Inputs {
68
source: InstallSource;
79
daemonConfig?: string;
10+
tcpPort?: number;
811
context: string;
912
setHost: boolean;
1013
rootless: boolean;
@@ -21,6 +24,7 @@ export function getInputs(): Inputs {
2124
return {
2225
source: source,
2326
daemonConfig: core.getInput('daemon-config'),
27+
tcpPort: Util.getInputNumber('tcp-port'),
2428
context: core.getInput('context'),
2529
setHost: core.getBooleanInput('set-host'),
2630
rootless: core.getBooleanInput('rootless')

0 commit comments

Comments
 (0)