mirror of
https://github.com/docker/setup-docker-action.git
synced 2025-06-14 07:27:13 +02:00
Compare commits
92 Commits
Author | SHA1 | Date | |
---|---|---|---|
635d07c09d | |||
34a3d15d63 | |||
560d8b137b | |||
482b1d74c1 | |||
f0ff59fe55 | |||
939fbc5e6e | |||
a0bafae0b8 | |||
a37e5b7d61 | |||
f6d883591e | |||
02c50bf68d | |||
6ec0bb821a | |||
3b54d1cfdf | |||
eaea3291c9 | |||
8b555caf8d | |||
40162ae1f1 | |||
7d1184f528 | |||
2419f2cbba | |||
332d315257 | |||
343f86705e | |||
bcd97be19b | |||
e02739be38 | |||
0d3aa44c5c | |||
a508bb356e | |||
3e94cecda0 | |||
701f172a16 | |||
90aad53e72 | |||
a9ddd812ce | |||
91cbfc7996 | |||
7de04ecfd0 | |||
8321f1dc18 | |||
ff9a36b06e | |||
cd5049af64 | |||
810b53a8ba | |||
ba5a8c50ed | |||
8677037d08 | |||
ff2661333b | |||
26145a578d | |||
0692aeebfc | |||
47611ea40b | |||
7bb565780b | |||
9794ac9406 | |||
701bc4e9ed | |||
958155397b | |||
de4e249b98 | |||
a2e96b1577 | |||
2e05eb17ec | |||
b52307508d | |||
a3485f7b8f | |||
1977c86a96 | |||
e98084b722 | |||
ca246a1805 | |||
40c64fb090 | |||
4acbcb8479 | |||
8f832606d8 | |||
4f5bb9fcef | |||
da44386179 | |||
f4a5b99d88 | |||
c794b17d99 | |||
e188b1d368 | |||
e0c95fcf69 | |||
25cb73f3c4 | |||
a93701ec9b | |||
3a19e60609 | |||
78318f8be5 | |||
54f3988321 | |||
f437b67409 | |||
06b9bc80b3 | |||
a6fae2d4e8 | |||
a4ef905acc | |||
41a5151e81 | |||
e96e0e2c98 | |||
8d0a8e33ff | |||
9bd97ff018 | |||
bca5e4d3e2 | |||
031a2987b7 | |||
753106f35c | |||
a1e4314d8f | |||
a7f3aad3f5 | |||
faa196892b | |||
796ce734cb | |||
3eb24de4f6 | |||
5bddaa4323 | |||
17819a1af9 | |||
d20884258e | |||
b74351ab97 | |||
0f5a011c3d | |||
99cad45695 | |||
aceee1722e | |||
0cb459c59a | |||
81886c7276 | |||
fdc6583d4e | |||
a4b15f09d5 |
5
.github/dependabot.yml
vendored
5
.github/dependabot.yml
vendored
@ -4,6 +4,11 @@ updates:
|
|||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
|
ignore:
|
||||||
|
# ignore this dependency
|
||||||
|
# it seems a bug with dependabot as pining to commit sha should not
|
||||||
|
# trigger a new version similar to https://github.com/docker/buildx/pull/2222#issuecomment-1919092153
|
||||||
|
- dependency-name: "docker/actions-toolkit"
|
||||||
labels:
|
labels:
|
||||||
- "dependencies"
|
- "dependencies"
|
||||||
- "bot"
|
- "bot"
|
||||||
|
99
.github/workflows/ci.yml
vendored
99
.github/workflows/ci.yml
vendored
@ -17,7 +17,7 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DOCKER_VERSION: v24.0.9
|
DOCKER_VERSION: v27.3.1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
@ -27,32 +27,21 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
|
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
|
||||||
- macos-13
|
- macos-13
|
||||||
- macos-latest
|
|
||||||
- windows-latest
|
- windows-latest
|
||||||
version:
|
version:
|
||||||
- pinned
|
- v27.3.1
|
||||||
- latest
|
- type=image,tag=27.3.1
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
-
|
|
||||||
name: Set version
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
if [ "${{ matrix.version }}" != "pinned" ]; then
|
|
||||||
echo "DOCKER_VERSION=${{ matrix.version }}" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
-
|
-
|
||||||
name: Set up Docker
|
name: Set up Docker
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: ${{ env.DOCKER_VERSION }}
|
version: ${{ matrix.version }}
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v2
|
|
||||||
|
|
||||||
channel:
|
channel:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@ -61,7 +50,8 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- macos-latest
|
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
|
||||||
|
- macos-13
|
||||||
- windows-latest
|
- windows-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
@ -71,12 +61,8 @@ jobs:
|
|||||||
name: Set up Docker
|
name: Set up Docker
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: v24.0.0-rc.4
|
version: ${{ env.DOCKER_VERSION }}
|
||||||
channel: test
|
channel: test
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v2
|
|
||||||
|
|
||||||
daemon-config:
|
daemon-config:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@ -85,7 +71,8 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- macos-latest
|
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
|
||||||
|
- macos-13
|
||||||
- windows-latest
|
- windows-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
@ -95,6 +82,7 @@ jobs:
|
|||||||
name: Set up Docker
|
name: Set up Docker
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
version: ${{ env.DOCKER_VERSION }}
|
||||||
daemon-config: |
|
daemon-config: |
|
||||||
{
|
{
|
||||||
"debug": true,
|
"debug": true,
|
||||||
@ -102,10 +90,6 @@ jobs:
|
|||||||
"containerd-snapshotter": true
|
"containerd-snapshotter": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v2
|
|
||||||
|
|
||||||
context:
|
context:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@ -114,7 +98,8 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- macos-latest
|
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
|
||||||
|
- macos-13
|
||||||
- windows-latest
|
- windows-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
@ -130,13 +115,10 @@ jobs:
|
|||||||
name: Check context
|
name: Check context
|
||||||
run: |
|
run: |
|
||||||
docker context inspect foo
|
docker context inspect foo
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v2
|
|
||||||
|
|
||||||
lima-start-args:
|
lima-start-args:
|
||||||
runs-on: macos-latest
|
#runs-on: macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
|
||||||
|
runs-on: macos-13
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
@ -144,15 +126,28 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Set up Docker
|
name: Set up Docker
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: ${{ env.DOCKER_VERSION }}
|
||||||
env:
|
env:
|
||||||
LIMA_START_ARGS: --cpus 4 --memory 8
|
LIMA_START_ARGS: --cpus 4 --memory 8
|
||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
containerd:
|
||||||
|
- containerd-system
|
||||||
|
- containerd-tarball
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Uninstall containerd
|
||||||
|
if: matrix.containerd == 'containerd-tarball'
|
||||||
|
run: |
|
||||||
|
sudo apt-get remove -y containerd.io
|
||||||
-
|
-
|
||||||
name: Set up Docker
|
name: Set up Docker
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -170,7 +165,7 @@ jobs:
|
|||||||
driver-opts: network=host
|
driver-opts: network=host
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: ./test
|
context: ./test
|
||||||
push: true
|
push: true
|
||||||
@ -180,10 +175,6 @@ jobs:
|
|||||||
name: Inspect
|
name: Inspect
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools inspect localhost:5000/name/app:latest --format '{{json .}}'
|
docker buildx imagetools inspect localhost:5000/name/app:latest --format '{{json .}}'
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v2
|
|
||||||
|
|
||||||
build-macos:
|
build-macos:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@ -191,8 +182,8 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
|
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
|
||||||
- macos-13
|
- macos-13
|
||||||
- macos-latest
|
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
@ -214,7 +205,7 @@ jobs:
|
|||||||
driver-opts: network=host
|
driver-opts: network=host
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: ./test
|
context: ./test
|
||||||
push: true
|
push: true
|
||||||
@ -224,10 +215,6 @@ jobs:
|
|||||||
name: Inspect
|
name: Inspect
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools inspect localhost:5000/name/app:latest --format '{{json .}}'
|
docker buildx imagetools inspect localhost:5000/name/app:latest --format '{{json .}}'
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v2
|
|
||||||
|
|
||||||
build-windows:
|
build-windows:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
@ -249,10 +236,6 @@ jobs:
|
|||||||
name: Inspect
|
name: Inspect
|
||||||
run: |
|
run: |
|
||||||
docker image inspect test
|
docker image inspect test
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v2
|
|
||||||
|
|
||||||
set-host:
|
set-host:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -264,12 +247,26 @@ jobs:
|
|||||||
name: Set up Docker
|
name: Set up Docker
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
version: ${{ env.DOCKER_VERSION }}
|
||||||
set-host: true
|
set-host: true
|
||||||
-
|
-
|
||||||
name: List contexts
|
name: List contexts
|
||||||
run: |
|
run: |
|
||||||
docker context ls
|
docker context ls
|
||||||
|
|
||||||
|
rootless:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
-
|
-
|
||||||
name: Dump context
|
name: Checkout
|
||||||
if: always()
|
uses: actions/checkout@v4
|
||||||
uses: crazy-max/ghaction-dump-context@v2
|
-
|
||||||
|
name: Set up Docker
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: ${{ env.DOCKER_VERSION }}
|
||||||
|
rootless: true
|
||||||
|
-
|
||||||
|
name: List contexts
|
||||||
|
run: |
|
||||||
|
docker context ls
|
||||||
|
7
.github/workflows/test.yml
vendored
7
.github/workflows/test.yml
vendored
@ -20,11 +20,12 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Test
|
name: Test
|
||||||
uses: docker/bake-action@v4
|
uses: docker/bake-action@v5
|
||||||
with:
|
with:
|
||||||
targets: test
|
targets: test
|
||||||
-
|
-
|
||||||
name: Upload coverage
|
name: Upload coverage
|
||||||
uses: codecov/codecov-action@v4
|
uses: codecov/codecov-action@v5
|
||||||
with:
|
with:
|
||||||
file: ./coverage/clover.xml
|
files: ./coverage/clover.xml
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
2
.github/workflows/validate.yml
vendored
2
.github/workflows/validate.yml
vendored
@ -40,6 +40,6 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Validate
|
name: Validate
|
||||||
uses: docker/bake-action@v4
|
uses: docker/bake-action@v5
|
||||||
with:
|
with:
|
||||||
targets: ${{ matrix.target }}
|
targets: ${{ matrix.target }}
|
||||||
|
874
.yarn/releases/yarn-3.6.3.cjs
vendored
874
.yarn/releases/yarn-3.6.3.cjs
vendored
File diff suppressed because one or more lines are too long
@ -11,5 +11,3 @@ nodeLinker: node-modules
|
|||||||
plugins:
|
plugins:
|
||||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
||||||
spec: "@yarnpkg/plugin-interactive-tools"
|
spec: "@yarnpkg/plugin-interactive-tools"
|
||||||
|
|
||||||
yarnPath: .yarn/releases/yarn-3.6.3.cjs
|
|
||||||
|
@ -9,6 +9,11 @@
|
|||||||
GitHub Action to set up (download and install) [Docker CE](https://docs.docker.com/engine/).
|
GitHub Action to set up (download and install) [Docker CE](https://docs.docker.com/engine/).
|
||||||
Works on Linux, macOS and Windows.
|
Works on Linux, macOS and Windows.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Does not work on macOS runners with ARM architecture (no nested virtualization):
|
||||||
|
> * https://github.com/crazy-max/ghaction-setup-docker/pull/53
|
||||||
|
> * https://github.com/docker/actions-toolkit/issues/317
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
___
|
___
|
||||||
@ -107,6 +112,7 @@ The following inputs can be used as `step.with` keys
|
|||||||
| `daemon-config` | String | | [Docker daemon JSON configuration](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file) |
|
| `daemon-config` | String | | [Docker daemon JSON configuration](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file) |
|
||||||
| `context` | String | `setup-docker-action` | Docker context name. |
|
| `context` | String | `setup-docker-action` | Docker context name. |
|
||||||
| `set-host` | Bool | `false` | Set `DOCKER_HOST` environment variable to docker socket path. |
|
| `set-host` | Bool | `false` | Set `DOCKER_HOST` environment variable to docker socket path. |
|
||||||
|
| `rootless` | Bool | `false` | Start daemon in rootless mode |
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
|
|
||||||
|
@ -19,12 +19,17 @@ describe('getInputs', () => {
|
|||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['version', 'v24.0.8'],
|
['version', 'v24.0.8'],
|
||||||
['set-host', 'false'],
|
['set-host', 'false'],
|
||||||
|
['rootless', 'false'],
|
||||||
]),
|
]),
|
||||||
{
|
{
|
||||||
version: 'v24.0.8',
|
source: {
|
||||||
channel: '',
|
type: 'archive',
|
||||||
|
version: 'v24.0.8',
|
||||||
|
channel: 'stable'
|
||||||
|
},
|
||||||
context: '',
|
context: '',
|
||||||
daemonConfig: '',
|
daemonConfig: '',
|
||||||
|
rootless: false,
|
||||||
setHost: false
|
setHost: false
|
||||||
} as context.Inputs
|
} as context.Inputs
|
||||||
],
|
],
|
||||||
@ -36,12 +41,17 @@ describe('getInputs', () => {
|
|||||||
['context', 'foo'],
|
['context', 'foo'],
|
||||||
['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`],
|
['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`],
|
||||||
['set-host', 'false'],
|
['set-host', 'false'],
|
||||||
|
['rootless', 'false'],
|
||||||
]),
|
]),
|
||||||
{
|
{
|
||||||
version: 'v24.0.0-rc.4',
|
source: {
|
||||||
channel: 'test',
|
type: 'archive',
|
||||||
|
version: 'v24.0.0-rc.4',
|
||||||
|
channel: 'test'
|
||||||
|
},
|
||||||
context: 'foo',
|
context: 'foo',
|
||||||
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
|
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
|
||||||
|
rootless: false,
|
||||||
setHost: false
|
setHost: false
|
||||||
} as context.Inputs
|
} as context.Inputs
|
||||||
],
|
],
|
||||||
@ -49,15 +59,132 @@ describe('getInputs', () => {
|
|||||||
2,
|
2,
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['set-host', 'true'],
|
['set-host', 'true'],
|
||||||
|
['rootless', 'false'],
|
||||||
]),
|
]),
|
||||||
{
|
{
|
||||||
version: 'latest',
|
source: {
|
||||||
channel: '',
|
type: 'archive',
|
||||||
|
version: 'latest',
|
||||||
|
channel: 'stable',
|
||||||
|
},
|
||||||
context: '',
|
context: '',
|
||||||
daemonConfig: '',
|
daemonConfig: '',
|
||||||
|
rootless: false,
|
||||||
setHost: true
|
setHost: true
|
||||||
} as context.Inputs
|
} as context.Inputs
|
||||||
]
|
],
|
||||||
|
[
|
||||||
|
3,
|
||||||
|
new Map<string, string>([
|
||||||
|
['version', 'type=image,tag=master'],
|
||||||
|
['context', 'foo'],
|
||||||
|
['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`],
|
||||||
|
['set-host', 'false'],
|
||||||
|
['rootless', 'false'],
|
||||||
|
]),
|
||||||
|
{
|
||||||
|
source: {
|
||||||
|
type: 'image',
|
||||||
|
tag: 'master',
|
||||||
|
},
|
||||||
|
context: 'foo',
|
||||||
|
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
|
||||||
|
rootless: false,
|
||||||
|
setHost: false
|
||||||
|
} as context.Inputs
|
||||||
|
],
|
||||||
|
[
|
||||||
|
4,
|
||||||
|
new Map<string, string>([
|
||||||
|
['version', 'type=image'],
|
||||||
|
['set-host', 'false'],
|
||||||
|
['rootless', 'false'],
|
||||||
|
]),
|
||||||
|
{
|
||||||
|
source: {
|
||||||
|
type: 'image',
|
||||||
|
tag: 'latest',
|
||||||
|
},
|
||||||
|
context: '',
|
||||||
|
daemonConfig: '',
|
||||||
|
rootless: false,
|
||||||
|
setHost: false
|
||||||
|
} as context.Inputs
|
||||||
|
],
|
||||||
|
[
|
||||||
|
5,
|
||||||
|
new Map<string, string>([
|
||||||
|
['version', 'type=archive'],
|
||||||
|
['set-host', 'false'],
|
||||||
|
['rootless', 'false'],
|
||||||
|
]),
|
||||||
|
{
|
||||||
|
source: {
|
||||||
|
type: 'archive',
|
||||||
|
version: 'latest',
|
||||||
|
channel: 'stable',
|
||||||
|
},
|
||||||
|
setHost: false,
|
||||||
|
context: '',
|
||||||
|
daemonConfig: '',
|
||||||
|
rootless: false,
|
||||||
|
} as context.Inputs
|
||||||
|
],
|
||||||
|
[
|
||||||
|
6,
|
||||||
|
new Map<string, string>([
|
||||||
|
['version', 'version=v27.2.0,channel=test'],
|
||||||
|
['set-host', 'false'],
|
||||||
|
['rootless', 'false'],
|
||||||
|
]),
|
||||||
|
{
|
||||||
|
source: {
|
||||||
|
type: 'archive',
|
||||||
|
version: 'v27.2.0',
|
||||||
|
channel: 'test',
|
||||||
|
},
|
||||||
|
setHost: false,
|
||||||
|
context: '',
|
||||||
|
daemonConfig: '',
|
||||||
|
rootless: false,
|
||||||
|
} as context.Inputs
|
||||||
|
],
|
||||||
|
[
|
||||||
|
7,
|
||||||
|
new Map<string, string>([
|
||||||
|
['version', 'type=image,tag=27.2.1'],
|
||||||
|
['set-host', 'false'],
|
||||||
|
['rootless', 'false'],
|
||||||
|
]),
|
||||||
|
{
|
||||||
|
source: {
|
||||||
|
type: 'image',
|
||||||
|
tag: '27.2.1',
|
||||||
|
},
|
||||||
|
setHost: false,
|
||||||
|
context: '',
|
||||||
|
daemonConfig: '',
|
||||||
|
rootless: false,
|
||||||
|
} as context.Inputs
|
||||||
|
],
|
||||||
|
[
|
||||||
|
8,
|
||||||
|
new Map<string, string>([
|
||||||
|
['version', 'type=image,tag=27.2.1'],
|
||||||
|
['set-host', 'false'],
|
||||||
|
['rootless', 'true']
|
||||||
|
]),
|
||||||
|
{
|
||||||
|
source: {
|
||||||
|
type: 'image',
|
||||||
|
tag: '27.2.1',
|
||||||
|
},
|
||||||
|
setHost: false,
|
||||||
|
context: '',
|
||||||
|
daemonConfig: '',
|
||||||
|
rootless: true,
|
||||||
|
} as context.Inputs
|
||||||
|
],
|
||||||
])(
|
])(
|
||||||
'[%d] given %p as inputs, returns %p',
|
'[%d] given %p as inputs, returns %p',
|
||||||
async (num: number, inputs: Map<string, string>, expected: context.Inputs) => {
|
async (num: number, inputs: Map<string, string>, expected: context.Inputs) => {
|
||||||
|
@ -24,6 +24,10 @@ inputs:
|
|||||||
description: 'Set DOCKER_HOST environment variable to docker socket path'
|
description: 'Set DOCKER_HOST environment variable to docker socket path'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
required: false
|
required: false
|
||||||
|
rootless:
|
||||||
|
description: 'Enable Docker rootless mode'
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
sock:
|
sock:
|
||||||
|
@ -4,8 +4,13 @@ ARG NODE_VERSION=20
|
|||||||
|
|
||||||
FROM node:${NODE_VERSION}-alpine AS base
|
FROM node:${NODE_VERSION}-alpine AS base
|
||||||
RUN apk add --no-cache cpio findutils git
|
RUN apk add --no-cache cpio findutils git
|
||||||
RUN yarn config set --home enableTelemetry 0
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/.yarn/cache <<EOT
|
||||||
|
corepack enable
|
||||||
|
yarn --version
|
||||||
|
yarn config set --home enableTelemetry 0
|
||||||
|
EOT
|
||||||
|
|
||||||
FROM base AS deps
|
FROM base AS deps
|
||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
95
dist/index.js
generated
vendored
95
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
3454
dist/licenses.txt
generated
vendored
3454
dist/licenses.txt
generated
vendored
File diff suppressed because it is too large
Load Diff
@ -26,9 +26,8 @@
|
|||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"packageManager": "yarn@3.6.3",
|
"packageManager": "yarn@3.6.3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.11.1",
|
||||||
"@docker/actions-toolkit": "^0.18.0",
|
"@docker/actions-toolkit": "^0.46.0"
|
||||||
"uuid": "^9.0.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.6.0",
|
"@types/node": "^20.6.0",
|
||||||
|
@ -1,19 +1,98 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
import {InstallSource} from '@docker/actions-toolkit/lib/docker/install';
|
||||||
|
import {parse} from 'csv-parse/sync';
|
||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
version: string;
|
source: InstallSource;
|
||||||
channel: string;
|
|
||||||
daemonConfig?: string;
|
daemonConfig?: string;
|
||||||
context: string;
|
context: string;
|
||||||
setHost: boolean;
|
setHost: boolean;
|
||||||
|
rootless: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getInputs(): Inputs {
|
export function getInputs(): Inputs {
|
||||||
|
const rawVersion = core.getInput('version') || 'latest';
|
||||||
|
const source = parseSource(rawVersion);
|
||||||
|
const channel = core.getInput('channel');
|
||||||
|
if (channel && source.type === 'archive') {
|
||||||
|
source.channel = channel;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
version: core.getInput('version') || 'latest',
|
source: source,
|
||||||
channel: core.getInput('channel'),
|
|
||||||
daemonConfig: core.getInput('daemon-config'),
|
daemonConfig: core.getInput('daemon-config'),
|
||||||
context: core.getInput('context'),
|
context: core.getInput('context'),
|
||||||
setHost: core.getBooleanInput('set-host')
|
setHost: core.getBooleanInput('set-host'),
|
||||||
|
rootless: core.getBooleanInput('rootless')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseSource(input: string): InstallSource {
|
||||||
|
let [type, version, channel, tag] = ['archive', 'latest', 'stable', 'latest'];
|
||||||
|
|
||||||
|
const fields = parse(input, {
|
||||||
|
relaxColumnCount: true,
|
||||||
|
skipEmptyLines: true
|
||||||
|
})[0];
|
||||||
|
for (const field of fields) {
|
||||||
|
const parts = field
|
||||||
|
.toString()
|
||||||
|
.split(/(?<=^[^=]+?)=/)
|
||||||
|
.map(item => item.trim());
|
||||||
|
|
||||||
|
switch (parts[0]) {
|
||||||
|
case 'type':
|
||||||
|
type = parts[1];
|
||||||
|
break;
|
||||||
|
case 'version':
|
||||||
|
version = parts[1];
|
||||||
|
break;
|
||||||
|
case 'channel':
|
||||||
|
channel = parts[1];
|
||||||
|
break;
|
||||||
|
case 'tag':
|
||||||
|
tag = parts[1];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (fields.length === 1) {
|
||||||
|
version = parts[0];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
throw new Error(`Invalid field: ${parts[0]}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!type) {
|
||||||
|
throw new Error(`Invalid type: ${type}`);
|
||||||
|
}
|
||||||
|
if (!channel) {
|
||||||
|
throw new Error(`Invalid channel: ${channel}`);
|
||||||
|
}
|
||||||
|
if (!version) {
|
||||||
|
throw new Error(`Invalid version: ${version}`);
|
||||||
|
}
|
||||||
|
if (!tag) {
|
||||||
|
throw new Error(`Invalid tag: ${tag}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
let src: InstallSource;
|
||||||
|
switch (type) {
|
||||||
|
case 'archive':
|
||||||
|
src = {
|
||||||
|
type: 'archive',
|
||||||
|
version: version,
|
||||||
|
channel: channel
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 'image':
|
||||||
|
src = {
|
||||||
|
type: 'image',
|
||||||
|
tag: tag
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error(`Invalid version: ${input}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return src;
|
||||||
|
}
|
||||||
|
10
src/main.ts
10
src/main.ts
@ -1,6 +1,6 @@
|
|||||||
|
import * as crypto from 'crypto';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as uuid from 'uuid';
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as actionsToolkit from '@docker/actions-toolkit';
|
import * as actionsToolkit from '@docker/actions-toolkit';
|
||||||
import {Install} from '@docker/actions-toolkit/lib/docker/install';
|
import {Install} from '@docker/actions-toolkit/lib/docker/install';
|
||||||
@ -13,7 +13,7 @@ actionsToolkit.run(
|
|||||||
// main
|
// main
|
||||||
async () => {
|
async () => {
|
||||||
const input: context.Inputs = context.getInputs();
|
const input: context.Inputs = context.getInputs();
|
||||||
const runDir = path.join(os.homedir(), `setup-docker-action-${uuid.v4()}`);
|
const runDir = path.join(os.homedir(), `setup-docker-action-${crypto.randomUUID().slice(0, 8)}`);
|
||||||
|
|
||||||
if (input.context == 'default') {
|
if (input.context == 'default') {
|
||||||
throw new Error(`'default' context cannot be used.`);
|
throw new Error(`'default' context cannot be used.`);
|
||||||
@ -21,13 +21,13 @@ actionsToolkit.run(
|
|||||||
|
|
||||||
const install = new Install({
|
const install = new Install({
|
||||||
runDir: runDir,
|
runDir: runDir,
|
||||||
version: input.version,
|
source: input.source,
|
||||||
channel: input.channel || 'stable',
|
rootless: input.rootless,
|
||||||
contextName: input.context || 'setup-docker-action',
|
contextName: input.context || 'setup-docker-action',
|
||||||
daemonConfig: input.daemonConfig
|
daemonConfig: input.daemonConfig
|
||||||
});
|
});
|
||||||
let toolDir;
|
let toolDir;
|
||||||
if (!(await Docker.isAvailable()) || input.version) {
|
if (!(await Docker.isAvailable()) || input.source) {
|
||||||
await core.group(`Download docker`, async () => {
|
await core.group(`Download docker`, async () => {
|
||||||
toolDir = await install.download();
|
toolDir = await install.download();
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user