Skip to content

Commit f7114cf

Browse files
usimdjtdor
andauthored
Allow to specify additional Docker args (#1)
Allow to specify additional `docker run` args Co-authored-by: Jörn-Thorben Hinz <[email protected]>
1 parent 6b75bf0 commit f7114cf

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

.github/workflows/test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,24 @@ jobs:
107107
test -f debian/artifacts/test_1_amd64.buildinfo
108108
test -f debian/artifacts/test_1_amd64.changes
109109
110+
extra-docker-args:
111+
runs-on: ubuntu-latest
112+
steps:
113+
- uses: actions/checkout@v2
114+
- run: cat test/Makefile_extra-docker-args >> test/Makefile
115+
- uses: ./
116+
env:
117+
DEB_BUILD_OPTIONS: noautodbgsym
118+
with:
119+
buildpackage-opts: --build=binary --no-sign
120+
source-dir: test
121+
extra-docker-args: --add-host extra-args-test:127.0.0.1
122+
- run: |
123+
dpkg --info debian/artifacts/test_1_amd64.deb
124+
dpkg --contents debian/artifacts/test_1_amd64.deb | grep ./usr/bin/mybin
125+
test -f debian/artifacts/test_1_amd64.buildinfo
126+
test -f debian/artifacts/test_1_amd64.changes
127+
110128
local-dockerfile:
111129
runs-on: ubuntu-latest
112130
steps:

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ dependencies. To change this, pass `--install-recommends` in
6363

6464
Optional and empty by default.
6565

66+
#### `extra-docker-args`
67+
Additional command-line arguments passed to `docker run` when the build
68+
container is started. This might be needed if specific volumes or network
69+
settings are required.
70+
71+
Optional and empty by default.
72+
6673
#### `host-arch`
6774
The architecture packages are built for. If this parameter is set,
6875
cross-compilation is set up with `apt-get` and `dpkg-buildpackage` as described

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ inputs:
1919
extra-build-deps:
2020
description: Extra packages to be installed as build dependencies
2121
required: false
22+
extra-docker-args:
23+
description: Additional arguments to 'docker run' when starting the build container
24+
required: false
2225
host-arch:
2326
description: Foreign architecture to setup cross-compilation for
2427
required: false
@@ -38,6 +41,7 @@ runs:
3841
INPUT_HOST_ARCH: ${{ inputs.host-arch }}
3942
INPUT_DOCKER_IMAGE: ${{ inputs.docker-image }}
4043
INPUT_EXTRA_BUILD_DEPS: ${{ inputs.extra-build-deps }}
44+
INPUT_EXTRA_DOCKER_ARGS: ${{ inputs.extra-docker-args }}
4145
INPUT_SOURCE_DIR: ${{ inputs.source-dir }}
4246
run: ${{ github.action_path }}/scripts/run.sh
4347
shell: bash

scripts/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ fi
7676
start_group "Starting build container"
7777
env > "$env_file"
7878
container_id=$(docker run \
79+
$INPUT_EXTRA_DOCKER_ARGS \
7980
--detach \
8081
--env-file="$env_file" \
8182
--env=GITHUB_ACTION_PATH=/github/action \

test/Makefile_extra-docker-args

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
.PHONY: test
3+
test:
4+
test "$$(awk '$$2 == "extra-args-test" { print $$1 }' /etc/hosts)" = "127.0.0.1"

0 commit comments

Comments
 (0)