diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml index 057cbe8..45d67a1 100644 --- a/.woodpecker/build.yaml +++ b/.woodpecker/build.yaml @@ -16,6 +16,9 @@ steps: username: {from_secret: kokuwa_io_username} password: {from_secret: kokuwa_io_password} platform: [linux/amd64, linux/arm64] + build-args: + NPM_CONFIG_REGISTRY: # reused from ci env + FOO: bar annotation: org.opencontainers.image.title: Buildctl WoodpeckerCI Plugin org.opencontainers.image.description: A WoodpeckerCI plugin for buildctl to build container images using a remote builtkitd instance. diff --git a/README.md b/README.md index 1f0a5c1..32eab59 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,9 @@ steps: annotation: org.opencontainers.image.title: My Image org.opencontainers.image.description: A description. + build-args: + NPM_CONFIG_REGISTRY: # reused from ci env + FOO: bar platform: [linux/amd64, linux/arm64] auth: registry.example.org: @@ -75,6 +78,7 @@ docker run --rm --user=$(id -u) --volume=$HOME:$HOME:ro --workdir=$PWD --env=PLU | `frontend` | PLUGIN_FRONTEND | `dockerfile.v0` | Only dockerfile frontend supported right now | | `context` | PLUGIN_CONTEXT | `$PWD` | Context directory to use for build | | `dockerfile` | PLUGIN_DOCKERFILE | `Dockerfile` | Dockerfile to use. | +| `build-args` | PLUGIN_BUILD_ARGS | `none` | Build args to pass to build | | `platform` | PLUGIN_PLATFORM | `none` | Target platform for container image. | | `source-epoch-date` | PLUGIN_SOURCE_DATE_EPOCH | `0` | Timestamp to use for reproduceable builds. | | `name` | PLUGIN_NAME | `none` | Images names where to push the image. | diff --git a/entrypoint.sh b/entrypoint.sh index 76543bc..342474a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -37,6 +37,10 @@ fi COMMAND+=" --frontend=$BUILDCTL_FRONTEND" COMMAND+=" --local=context=$BUILDCTL_CONTEXT" COMMAND+=" --local=dockerfile=$BUILDCTL_DOCKERFILE" +if [[ -n "${PLUGIN_BUILD_ARGS:-}" ]]; then + env|sort + OUTPUT+="$(echo "$PLUGIN_BUILD_ARGS" | jq --join-output 'keys[] as $k|",annotation.\($k)=\(.[$k])"')" +fi if [[ -n "${PLUGIN_PLATFORM:-}" ]]; then COMMAND+=" --opt=platform=$PLUGIN_PLATFORM" fi