Skip to content

Commit e1b7f96

Browse files
authored
Merge pull request #338 from crazy-max/network
Add network input
2 parents 8891861 + 5a4a26c commit e1b7f96

File tree

6 files changed

+39
-0
lines changed

6 files changed

+39
-0
lines changed

.github/workflows/ci.yml

+24
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,30 @@ jobs:
290290
if: always()
291291
uses: crazy-max/ghaction-dump-context@v1
292292

293+
network:
294+
runs-on: ubuntu-latest
295+
steps:
296+
-
297+
name: Checkout
298+
uses: actions/checkout@v2
299+
-
300+
name: Set up Docker Buildx
301+
uses: docker/setup-buildx-action@v1
302+
-
303+
name: List networks
304+
run: docker network ls
305+
-
306+
name: Build
307+
uses: ./
308+
with:
309+
context: ./test
310+
tags: name/app:latest
311+
network: host
312+
-
313+
name: Dump context
314+
if: always()
315+
uses: crazy-max/ghaction-dump-context@v1
316+
293317
multi:
294318
runs-on: ubuntu-latest
295319
strategy:

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ Following inputs can be used as `step.with` keys
204204
| `file` | String | Path to the Dockerfile. (default `{context}/Dockerfile`) |
205205
| `labels` | List | List of metadata for an image |
206206
| `load` | Bool | [Load](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#load) is a shorthand for `--output=type=docker` (default `false`) |
207+
| `network` | String | Set the networking mode for the `RUN` instructions during build |
207208
| `no-cache` | Bool | Do not use cache when building the image (default `false`) |
208209
| `outputs` | List | List of [output destinations](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#output) (format: `type=local,dest=path`) |
209210
| `platforms` | List/CSV | List of [target platforms](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#platform) for build |

__tests__/context.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ ccc`],
346346
['secret-files', `MY_SECRET=${path.join(__dirname, 'fixtures', 'secret.txt').split(path.sep).join(path.posix.sep)}`],
347347
['file', './test/Dockerfile'],
348348
['builder', 'builder-git-context-2'],
349+
['network', 'host'],
349350
['push', 'true']
350351
]),
351352
[
@@ -355,6 +356,7 @@ ccc`],
355356
'--secret', 'id=MY_SECRET,src=/tmp/.docker-build-push-jest/.tmpname-jest',
356357
'--file', './test/Dockerfile',
357358
'--builder', 'builder-git-context-2',
359+
'--network', 'host',
358360
'--push',
359361
'https://github.com/docker/build-push-action.git#heads/master'
360362
]

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ inputs:
3535
description: "Load is a shorthand for --output=type=docker"
3636
required: false
3737
default: 'false'
38+
network:
39+
description: "Set the networking mode for the RUN instructions during build"
40+
required: false
3841
no-cache:
3942
description: "Do not use cache when building the image"
4043
required: false

dist/index.js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.ts

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface Inputs {
2222
file: string;
2323
labels: string[];
2424
load: boolean;
25+
network: string;
2526
noCache: boolean;
2627
outputs: string[];
2728
platforms: string[];
@@ -66,6 +67,7 @@ export async function getInputs(defaultContext: string): Promise<Inputs> {
6667
file: core.getInput('file'),
6768
labels: await getInputList('labels', true),
6869
load: /true/i.test(core.getInput('load')),
70+
network: core.getInput('network'),
6971
noCache: /true/i.test(core.getInput('no-cache')),
7072
outputs: await getInputList('outputs', true),
7173
platforms: await getInputList('platforms'),
@@ -163,6 +165,9 @@ async function getCommonArgs(inputs: Inputs): Promise<Array<string>> {
163165
if (inputs.load) {
164166
args.push('--load');
165167
}
168+
if (inputs.network) {
169+
args.push('--network', inputs.network);
170+
}
166171
if (inputs.push) {
167172
args.push('--push');
168173
}

0 commit comments

Comments
 (0)