mirror of
https://github.com/docker/setup-docker-action.git
synced 2025-06-16 00:07:13 +02:00
Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
92e1039e6d | |||
50de6aefe9 | |||
a2ce6b1772 | |||
5265cc143e | |||
008acd5bc6 | |||
e8785f775f | |||
cb1f376ddb | |||
c3a68cbeca | |||
0a682c046a | |||
e4a53ed864 | |||
3dcc76c352 | |||
d131482129 | |||
59b62980d1 | |||
475e5bf1db | |||
a7db17d9b4 | |||
34c4964b4a | |||
3e758a2d14 |
130
.github/workflows/ci.yml
vendored
130
.github/workflows/ci.yml
vendored
@ -29,4 +29,132 @@ jobs:
|
|||||||
name: Set up Docker
|
name: Set up Docker
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 23.0.0
|
version: v23.0.0
|
||||||
|
|
||||||
|
channel:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- macos-latest
|
||||||
|
- windows-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: v23.0.0-rc.4
|
||||||
|
channel: test
|
||||||
|
|
||||||
|
context:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- macos-latest
|
||||||
|
- windows-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: v23.0.0
|
||||||
|
context: foo
|
||||||
|
-
|
||||||
|
name: Check context
|
||||||
|
run: |
|
||||||
|
docker context inspect foo
|
||||||
|
|
||||||
|
build-linux:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
registry:
|
||||||
|
image: registry:2
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker
|
||||||
|
uses: ./
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
driver: docker
|
||||||
|
driver-opts: network=host
|
||||||
|
-
|
||||||
|
name: Build and push
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: ./test
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
localhost:5000/name/app:latest
|
||||||
|
-
|
||||||
|
name: Inspect
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools inspect localhost:5000/name/app:latest --format '{{json .}}'
|
||||||
|
|
||||||
|
build-macos:
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker
|
||||||
|
uses: ./
|
||||||
|
-
|
||||||
|
name: Start registry
|
||||||
|
run: |
|
||||||
|
docker run -d -p 5000:5000 --restart=always --name registry registry:2
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
driver: docker
|
||||||
|
driver-opts: network=host
|
||||||
|
-
|
||||||
|
name: Build and push
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: ./test
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
localhost:5000/name/app:latest
|
||||||
|
-
|
||||||
|
name: Inspect
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools inspect localhost:5000/name/app:latest --format '{{json .}}'
|
||||||
|
|
||||||
|
build-windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker
|
||||||
|
uses: ./
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
working-directory: ./test
|
||||||
|
run: |
|
||||||
|
docker build -f win.Dockerfile -t test .
|
||||||
|
-
|
||||||
|
name: Inspect
|
||||||
|
run: |
|
||||||
|
docker image inspect test
|
||||||
|
30
README.md
30
README.md
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
## About
|
## About
|
||||||
|
|
||||||
GitHub Action to set up [Docker CE](https://docs.docker.com/engine/). Works on
|
GitHub Action to set up (download and install) [Docker CE](https://docs.docker.com/engine/).
|
||||||
Linux, macOS and Windows.
|
Works on Linux, macOS and Windows.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@ -17,6 +17,7 @@ ___
|
|||||||
* [Customizing](#customizing)
|
* [Customizing](#customizing)
|
||||||
* [inputs](#inputs)
|
* [inputs](#inputs)
|
||||||
* [Contributing](#contributing)
|
* [Contributing](#contributing)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -33,8 +34,6 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Set up Docker
|
name: Set up Docker
|
||||||
uses: crazy-max/ghaction-setup-docker@v1
|
uses: crazy-max/ghaction-setup-docker@v1
|
||||||
with:
|
|
||||||
version: 23.0.1
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Customizing
|
## Customizing
|
||||||
@ -43,11 +42,24 @@ jobs:
|
|||||||
|
|
||||||
Following inputs can be used as `step.with` keys
|
Following inputs can be used as `step.with` keys
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Default | Description |
|
||||||
|-----------|--------|-------------------------------------|
|
|-----------|--------|-----------------------|---------------------------------------------------------------------------------------------------|
|
||||||
| `version` | String | Docker CE version (e.g., `23.0.1`). |
|
| `version` | String | `latest` | Docker CE version (e.g., `v23.0.1`). |
|
||||||
|
| `channel` | String | `stable` | Docker CE [channel](https://download.docker.com/linux/static/) (e.g, `stable`, `edge` or `test`). |
|
||||||
|
| `context` | String | `setup-docker-action` | Docker context name. |
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Want to contribute? Awesome! You can find information about contributing to
|
Want to contribute? Awesome! The most basic way to show your support is to star
|
||||||
this project in the [CONTRIBUTING.md](/.github/CONTRIBUTING.md)
|
the project, or to raise issues. If you want to open a pull request, please
|
||||||
|
read the [contributing guidelines](.github/CONTRIBUTING.md).
|
||||||
|
|
||||||
|
You can also support this project by [**becoming a sponsor on GitHub**](https://github.com/sponsors/crazy-max)
|
||||||
|
or by making a [PayPal donation](https://www.paypal.me/crazyws) to ensure this
|
||||||
|
journey continues indefinitely!
|
||||||
|
|
||||||
|
Thanks again for your support, it is much appreciated! :pray:
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Apache-2.0. See `LICENSE` for more details.
|
||||||
|
@ -17,10 +17,34 @@ describe('getInputs', () => {
|
|||||||
[
|
[
|
||||||
0,
|
0,
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['version', '23.0.1'],
|
['version', 'v23.0.1'],
|
||||||
]),
|
]),
|
||||||
{
|
{
|
||||||
version: '23.0.1',
|
version: 'v23.0.1',
|
||||||
|
channel: '',
|
||||||
|
context: '',
|
||||||
|
} as context.Inputs
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
new Map<string, string>([
|
||||||
|
['version', 'v23.0.0-rc.4'],
|
||||||
|
['channel', 'test'],
|
||||||
|
['context', 'foo'],
|
||||||
|
]),
|
||||||
|
{
|
||||||
|
version: 'v23.0.0-rc.4',
|
||||||
|
channel: 'test',
|
||||||
|
context: 'foo',
|
||||||
|
} as context.Inputs
|
||||||
|
],
|
||||||
|
[
|
||||||
|
2,
|
||||||
|
new Map<string, string>([]),
|
||||||
|
{
|
||||||
|
version: 'latest',
|
||||||
|
channel: '',
|
||||||
|
context: '',
|
||||||
} as context.Inputs
|
} as context.Inputs
|
||||||
]
|
]
|
||||||
])(
|
])(
|
||||||
|
13
action.yml
13
action.yml
@ -1,14 +1,21 @@
|
|||||||
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
|
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
|
||||||
name: 'Docker Setup Docker'
|
name: 'Docker Setup Docker'
|
||||||
description: 'Set up Docker'
|
description: 'Set up Docker for use in GitHub Actions by downloading and installing a version of Docker CE'
|
||||||
author: 'docker'
|
author: 'crazy-max'
|
||||||
branding:
|
branding:
|
||||||
icon: 'anchor'
|
icon: 'anchor'
|
||||||
color: 'blue'
|
color: 'blue'
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
description: 'Docker CE version. (e.g, 23.0.1)'
|
description: 'Docker CE version. (e.g, v23.0.1)'
|
||||||
|
required: false
|
||||||
|
default: 'latest'
|
||||||
|
channel:
|
||||||
|
description: 'Docker CE channel. (e.g, stable, edge or test)'
|
||||||
|
required: false
|
||||||
|
context:
|
||||||
|
description: 'Docker context name. (default setup-docker-action)'
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
|
6
dist/index.js
generated
vendored
6
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
12
package.json
12
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "docker-setup-docker",
|
"name": "docker-setup-docker",
|
||||||
"description": "Set up Docker CE",
|
"description": "Set up Docker for use in GitHub Actions by downloading and installing a version of Docker CE",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "ncc build src/main.ts --source-map --minify --license licenses.txt",
|
"build": "ncc build src/main.ts --source-map --minify --license licenses.txt",
|
||||||
@ -18,17 +18,11 @@
|
|||||||
"docker",
|
"docker",
|
||||||
"engine"
|
"engine"
|
||||||
],
|
],
|
||||||
"author": "Docker",
|
"author": "CrazyMax",
|
||||||
"contributors": [
|
|
||||||
{
|
|
||||||
"name": "CrazyMax",
|
|
||||||
"url": "https://crazymax.dev"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@docker/actions-toolkit": "^0.1.0-beta.17",
|
"@docker/actions-toolkit": "^0.1.0-beta.18",
|
||||||
"uuid": "^9.0.0"
|
"uuid": "^9.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -2,10 +2,14 @@ import * as core from '@actions/core';
|
|||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
version: string;
|
version: string;
|
||||||
|
channel: string;
|
||||||
|
context: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getInputs(): Inputs {
|
export function getInputs(): Inputs {
|
||||||
return {
|
return {
|
||||||
version: core.getInput('version')
|
version: core.getInput('version') || 'latest',
|
||||||
|
channel: core.getInput('channel'),
|
||||||
|
context: core.getInput('context')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
23
src/main.ts
23
src/main.ts
@ -13,18 +13,27 @@ 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 install = new Install();
|
if (input.context == 'default') {
|
||||||
|
throw new Error(`'default' context cannot be used.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const install = new Install({
|
||||||
|
runDir: runDir,
|
||||||
|
version: input.version,
|
||||||
|
channel: input.channel || 'stable',
|
||||||
|
contextName: input.context || 'setup-docker-action'
|
||||||
|
});
|
||||||
let toolDir;
|
let toolDir;
|
||||||
if (!(await Docker.isAvailable()) || input.version) {
|
if (!(await Docker.isAvailable()) || input.version) {
|
||||||
await core.group(`Download docker`, async () => {
|
await core.group(`Download docker`, async () => {
|
||||||
toolDir = await install.download(input.version || 'latest');
|
toolDir = await install.download();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (toolDir) {
|
if (toolDir) {
|
||||||
const runDir = path.join(os.homedir(), `setup-docker-action-${uuid.v4()}`);
|
|
||||||
stateHelper.setRunDir(runDir);
|
stateHelper.setRunDir(runDir);
|
||||||
await install.install(toolDir, runDir, input.version);
|
await install.install();
|
||||||
}
|
}
|
||||||
|
|
||||||
await core.group(`Docker info`, async () => {
|
await core.group(`Docker info`, async () => {
|
||||||
@ -37,7 +46,9 @@ actionsToolkit.run(
|
|||||||
if (stateHelper.runDir.length == 0) {
|
if (stateHelper.runDir.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const install = new Install();
|
const install = new Install({
|
||||||
await install.tearDown(stateHelper.runDir);
|
runDir: stateHelper.runDir
|
||||||
|
});
|
||||||
|
await install.tearDown();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
9
test/Dockerfile
Normal file
9
test/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
FROM --platform=$BUILDPLATFORM golang:alpine AS build
|
||||||
|
ARG TARGETPLATFORM
|
||||||
|
ARG BUILDPLATFORM
|
||||||
|
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" > /log
|
||||||
|
|
||||||
|
FROM alpine
|
||||||
|
COPY --from=build /log /log
|
22
test/hello.txt
Normal file
22
test/hello.txt
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Hello from Docker!
|
||||||
|
This message shows that your installation appears to be working correctly.
|
||||||
|
|
||||||
|
To generate this message, Docker took the following steps:
|
||||||
|
1. The Docker client contacted the Docker daemon.
|
||||||
|
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
|
||||||
|
(windows-amd64, nanoserver-1809)
|
||||||
|
3. The Docker daemon created a new container from that image which runs the
|
||||||
|
executable that produces the output you are currently reading.
|
||||||
|
4. The Docker daemon streamed that output to the Docker client, which sent it
|
||||||
|
to your terminal.
|
||||||
|
|
||||||
|
To try something more ambitious, you can run a Windows Server container with:
|
||||||
|
PS C:\> docker run -it mcr.microsoft.com/windows/servercore:ltsc2019 powershell
|
||||||
|
|
||||||
|
Share images, automate workflows, and more with a free Docker ID:
|
||||||
|
https://hub.docker.com/
|
||||||
|
|
||||||
|
For more examples and ideas, visit:
|
||||||
|
https://docs.docker.com/get-started/
|
||||||
|
|
3
test/win.Dockerfile
Normal file
3
test/win.Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
FROM mcr.microsoft.com/windows/nanoserver:1809
|
||||||
|
COPY hello.txt C:
|
||||||
|
CMD ["cmd", "/C", "type C:\\hello.txt"]
|
17
yarn.lock
17
yarn.lock
@ -352,10 +352,10 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@cspotcode/source-map-consumer" "0.8.0"
|
"@cspotcode/source-map-consumer" "0.8.0"
|
||||||
|
|
||||||
"@docker/actions-toolkit@^0.1.0-beta.17":
|
"@docker/actions-toolkit@^0.1.0-beta.18":
|
||||||
version "0.1.0-beta.17"
|
version "0.1.0-beta.18"
|
||||||
resolved "https://registry.yarnpkg.com/@docker/actions-toolkit/-/actions-toolkit-0.1.0-beta.17.tgz#71efff853f34aba59e89e13d05cf9eaf599af2a2"
|
resolved "https://registry.yarnpkg.com/@docker/actions-toolkit/-/actions-toolkit-0.1.0-beta.18.tgz#cf5c61059dba81d8e0f595a0bcc67b125ec25f09"
|
||||||
integrity sha512-oB3qda7bTDZ3hBJxZS4TO5IK9OvelAwQicLYrfi1Uw3ROTTjpSU4sttUupY499cviLlQ/9vcTdB+8ZR+pBi1ww==
|
integrity sha512-WzayeV7ZNaqWyozWUI1QVZefacqWUV9gT/w54YiiizG145YJEMov6FXYMec2OE2tsTJ9uI1UgOl5hW/HFdG1mA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@actions/core" "^1.10.0"
|
"@actions/core" "^1.10.0"
|
||||||
"@actions/exec" "^1.1.1"
|
"@actions/exec" "^1.1.1"
|
||||||
@ -3065,7 +3065,7 @@ saxes@^5.0.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
xmlchars "^2.2.0"
|
xmlchars "^2.2.0"
|
||||||
|
|
||||||
semver@7.x, semver@^7.3.2, semver@^7.3.7, semver@^7.3.8:
|
semver@7.x, semver@^7.3.2, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8:
|
||||||
version "7.3.8"
|
version "7.3.8"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
|
||||||
integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
|
integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
|
||||||
@ -3077,13 +3077,6 @@ semver@^6.0.0, semver@^6.1.0, semver@^6.3.0:
|
|||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
||||||
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
||||||
|
|
||||||
semver@^7.3.5:
|
|
||||||
version "7.3.5"
|
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
|
|
||||||
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
|
|
||||||
dependencies:
|
|
||||||
lru-cache "^6.0.0"
|
|
||||||
|
|
||||||
shebang-command@^2.0.0:
|
shebang-command@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
|
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
|
||||||
|
Reference in New Issue
Block a user