Skip to content

Commit

Permalink
Merge pull request #24 from crazy-max/daemon-config
Browse files Browse the repository at this point in the history
daemon-config input
  • Loading branch information
crazy-max authored Aug 27, 2023
2 parents d298db0 + 0e98cdf commit 2c7b4c9
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 8 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,35 @@ jobs:
if: always()
uses: crazy-max/ghaction-dump-context@v2

daemon-config:
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:
daemon-config: |
{
"debug": true,
"features": {
"containerd-snapshotter": true
}
}
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v2

context:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
45 changes: 40 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Works on Linux, macOS and Windows.
___

* [Usage](#usage)
* [Quick start](#quick-start)
* [Daemon configuration](#daemon-configuration)
* [Customizing](#customizing)
* [inputs](#inputs)
* [Notes](#notes)
Expand All @@ -22,6 +24,30 @@ ___

## Usage

### Quick start

```yaml
name: ci

on:
push:

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up Docker
uses: crazy-max/ghaction-setup-docker@v1
```
### Daemon configuration
You can [configure the Docker daemon](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file)
using the `daemon-config` input. In the following example, we configure the
Docker daemon to enable debug and the [containerd image store](https://docs.docker.com/storage/containerd/)
feature:

```yaml
name: ci
Expand All @@ -35,6 +61,14 @@ jobs:
-
name: Set up Docker
uses: crazy-max/ghaction-setup-docker@v1
with:
daemon-config: |
{
"debug": true,
"features": {
"containerd-snapshotter": true
}
}
```

## Customizing
Expand All @@ -43,11 +77,12 @@ jobs:

Following inputs can be used as `step.with` keys

| 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. |
| 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`). |
| `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. |

## Notes

Expand Down
4 changes: 4 additions & 0 deletions __tests__/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('getInputs', () => {
version: 'v23.0.1',
channel: '',
context: '',
daemonConfig: '',
} as context.Inputs
],
[
Expand All @@ -31,11 +32,13 @@ describe('getInputs', () => {
['version', 'v23.0.0-rc.4'],
['channel', 'test'],
['context', 'foo'],
['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`],
]),
{
version: 'v23.0.0-rc.4',
channel: 'test',
context: 'foo',
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
} as context.Inputs
],
[
Expand All @@ -45,6 +48,7 @@ describe('getInputs', () => {
version: 'latest',
channel: '',
context: '',
daemonConfig: '',
} as context.Inputs
]
])(
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ inputs:
channel:
description: 'Docker CE channel. (e.g, stable, edge or test)'
required: false
daemon-config:
description: 'Docker daemon JSON configuration'
required: false
context:
description: 'Docker context name. (default setup-docker-action)'
required: false
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import * as core from '@actions/core';
export interface Inputs {
version: string;
channel: string;
daemonConfig?: string;
context: string;
}

export function getInputs(): Inputs {
return {
version: core.getInput('version') || 'latest',
channel: core.getInput('channel'),
daemonConfig: core.getInput('daemon-config'),
context: core.getInput('context')
};
}
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ actionsToolkit.run(
runDir: runDir,
version: input.version,
channel: input.channel || 'stable',
contextName: input.context || 'setup-docker-action'
contextName: input.context || 'setup-docker-action',
daemonConfig: input.daemonConfig
});
let toolDir;
if (!(await Docker.isAvailable()) || input.version) {
Expand Down

0 comments on commit 2c7b4c9

Please sign in to comment.