From f7be842ce58dc07db3448fd8b44e7cda6c910191 Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Thu, 13 Jun 2024 18:23:07 +0100 Subject: [PATCH] Add the optional build-arg input Resolves #38 --- action.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ff0a2a8..204cab9 100644 --- a/action.yml +++ b/action.yml @@ -42,6 +42,12 @@ inputs: description: Image tag, e.g. latest. Will overwrite the tag latest tag on a push, and have no effect on a release. required: false + # https://docs.docker.com/build/guide/build-args/ + build_arg: + description: Additional build argument to be passed to the Dockerfile (e.g. NODE_AUTH_TOKEN=s3cr3t) + required: false + default: "FOO=bar" + runs: using: "composite" steps: @@ -84,7 +90,7 @@ runs: export BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") export GITHUB_URL=https://github.com/${{ github.repository }} - echo "::group::Building the Docker image: ${{ inputs.repository }}/${IMAGE_NAME}:${COMMIT_TAG} from ${{ inputs.dockerfile }} in ${{ inputs.context}} context ..." + echo "::group::Building the Docker image: ${{ inputs.repository }}/${IMAGE_NAME}:${COMMIT_TAG} from ${{ inputs.dockerfile }} in ${{ inputs.context }} context ..." # https://docs.docker.com/develop/develop-images/build_enhancements/ # https://docs.docker.com/engine/reference/commandline/build/#specifying-external-cache-sources @@ -97,6 +103,8 @@ runs: --build-arg BUILD_DATE=${BUILD_DATE} \ --build-arg GITHUB_SHA=${GITHUB_SHA} \ \ + --build-arg ${{ inputs.build_arg }} \ + \ --tag ${{ inputs.repository }}/${IMAGE_NAME}:${COMMIT_TAG} \ --tag docker.io/${IMAGE_NAME}:${COMMIT_TAG} \ \