17 Commits

Author SHA1 Message Date
92e1039e6d Merge pull request #9 from crazy-max/update-community-files
update community files
2023-03-10 10:19:53 +00:00
50de6aefe9 update community files 2023-03-10 11:17:01 +01:00
a2ce6b1772 Merge pull request #8 from crazy-max/fix-version-latest
fix version to latest
2023-03-10 10:15:15 +00:00
5265cc143e update generated content 2023-03-10 11:09:24 +01:00
008acd5bc6 fix version to latest 2023-03-10 11:09:18 +01:00
e8785f775f Merge pull request #3 from crazy-max/ci-test
ci: test build Dockerfile
2023-03-10 10:04:19 +00:00
cb1f376ddb ci: test build Dockerfile 2023-03-10 10:54:14 +01:00
c3a68cbeca Merge pull request #7 from crazy-max/context-input
context input
2023-03-10 01:35:42 +00:00
0a682c046a update generated content 2023-03-10 02:01:38 +01:00
e4a53ed864 context input 2023-03-10 02:01:38 +01:00
3dcc76c352 Merge pull request #6 from crazy-max/channel
channel support
2023-03-10 00:08:13 +00:00
d131482129 update generated content 2023-03-10 00:57:37 +01:00
59b62980d1 channel support 2023-03-10 00:57:37 +01:00
475e5bf1db Merge pull request #5 from crazy-max/dependabot/npm_and_yarn/docker/actions-toolkit-0.1.0-beta.18
Bump @docker/actions-toolkit from 0.1.0-beta.17 to 0.1.0-beta.18
2023-03-09 23:31:13 +00:00
a7db17d9b4 update generated content 2023-03-10 00:26:42 +01:00
34c4964b4a use new implementation 2023-03-10 00:26:41 +01:00
3e758a2d14 Bump @docker/actions-toolkit from 0.1.0-beta.17 to 0.1.0-beta.18
Bumps [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.1.0-beta.17 to 0.1.0-beta.18.
- [Release notes](https://github.com/docker/actions-toolkit/releases)
- [Commits](https://github.com/docker/actions-toolkit/compare/v0.1.0-beta.17...v0.1.0-beta.18)

---
updated-dependencies:
- dependency-name: "@docker/actions-toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-08 11:17:48 +00:00
13 changed files with 254 additions and 47 deletions

View File

@ -29,4 +29,132 @@ jobs:
name: Set up Docker
uses: ./
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

View File

@ -6,8 +6,8 @@
## About
GitHub Action to set up [Docker CE](https://docs.docker.com/engine/). Works on
Linux, macOS and Windows.
GitHub Action to set up (download and install) [Docker CE](https://docs.docker.com/engine/).
Works on Linux, macOS and Windows.
![Screenshot](.github/setup-docker-action.png)
@ -17,6 +17,7 @@ ___
* [Customizing](#customizing)
* [inputs](#inputs)
* [Contributing](#contributing)
* [License](#license)
## Usage
@ -33,8 +34,6 @@ jobs:
-
name: Set up Docker
uses: crazy-max/ghaction-setup-docker@v1
with:
version: 23.0.1
```
## Customizing
@ -43,11 +42,24 @@ jobs:
Following inputs can be used as `step.with` keys
| Name | Type | Description |
|-----------|--------|-------------------------------------|
| `version` | String | Docker CE version (e.g., `23.0.1`). |
| Name | Type | Default | Description |
|-----------|--------|-----------------------|---------------------------------------------------------------------------------------------------|
| `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
Want to contribute? Awesome! You can find information about contributing to
this project in the [CONTRIBUTING.md](/.github/CONTRIBUTING.md)
Want to contribute? Awesome! The most basic way to show your support is to star
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.

View File

@ -17,10 +17,34 @@ describe('getInputs', () => {
[
0,
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
]
])(

View File

@ -1,14 +1,21 @@
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
name: 'Docker Setup Docker'
description: 'Set up Docker'
author: 'docker'
description: 'Set up Docker for use in GitHub Actions by downloading and installing a version of Docker CE'
author: 'crazy-max'
branding:
icon: 'anchor'
color: 'blue'
inputs:
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
runs:

6
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"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",
"scripts": {
"build": "ncc build src/main.ts --source-map --minify --license licenses.txt",
@ -18,17 +18,11 @@
"docker",
"engine"
],
"author": "Docker",
"contributors": [
{
"name": "CrazyMax",
"url": "https://crazymax.dev"
}
],
"author": "CrazyMax",
"license": "Apache-2.0",
"dependencies": {
"@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"
},
"devDependencies": {

View File

@ -2,10 +2,14 @@ import * as core from '@actions/core';
export interface Inputs {
version: string;
channel: string;
context: string;
}
export function getInputs(): Inputs {
return {
version: core.getInput('version')
version: core.getInput('version') || 'latest',
channel: core.getInput('channel'),
context: core.getInput('context')
};
}

View File

@ -13,18 +13,27 @@ actionsToolkit.run(
// main
async () => {
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;
if (!(await Docker.isAvailable()) || input.version) {
await core.group(`Download docker`, async () => {
toolDir = await install.download(input.version || 'latest');
toolDir = await install.download();
});
}
if (toolDir) {
const runDir = path.join(os.homedir(), `setup-docker-action-${uuid.v4()}`);
stateHelper.setRunDir(runDir);
await install.install(toolDir, runDir, input.version);
await install.install();
}
await core.group(`Docker info`, async () => {
@ -37,7 +46,9 @@ actionsToolkit.run(
if (stateHelper.runDir.length == 0) {
return;
}
const install = new Install();
await install.tearDown(stateHelper.runDir);
const install = new Install({
runDir: stateHelper.runDir
});
await install.tearDown();
}
);

9
test/Dockerfile Normal file
View 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
View 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
View File

@ -0,0 +1,3 @@
FROM mcr.microsoft.com/windows/nanoserver:1809
COPY hello.txt C:
CMD ["cmd", "/C", "type C:\\hello.txt"]

View File

@ -352,10 +352,10 @@
dependencies:
"@cspotcode/source-map-consumer" "0.8.0"
"@docker/actions-toolkit@^0.1.0-beta.17":
version "0.1.0-beta.17"
resolved "https://registry.yarnpkg.com/@docker/actions-toolkit/-/actions-toolkit-0.1.0-beta.17.tgz#71efff853f34aba59e89e13d05cf9eaf599af2a2"
integrity sha512-oB3qda7bTDZ3hBJxZS4TO5IK9OvelAwQicLYrfi1Uw3ROTTjpSU4sttUupY499cviLlQ/9vcTdB+8ZR+pBi1ww==
"@docker/actions-toolkit@^0.1.0-beta.18":
version "0.1.0-beta.18"
resolved "https://registry.yarnpkg.com/@docker/actions-toolkit/-/actions-toolkit-0.1.0-beta.18.tgz#cf5c61059dba81d8e0f595a0bcc67b125ec25f09"
integrity sha512-WzayeV7ZNaqWyozWUI1QVZefacqWUV9gT/w54YiiizG145YJEMov6FXYMec2OE2tsTJ9uI1UgOl5hW/HFdG1mA==
dependencies:
"@actions/core" "^1.10.0"
"@actions/exec" "^1.1.1"
@ -3065,7 +3065,7 @@ saxes@^5.0.1:
dependencies:
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"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
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"
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:
version "2.0.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"