diff --git a/README.md b/README.md index d9bbdef..f10abdb 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,11 @@ Only GitHub Container Registry (ghcr.io) is supported so far. # Optional, defaults to package name build_context: ./frontend + # Sets a list of [build-time variables](https://docs.docker.com/engine/reference/commandline/buildx_build/#build-arg) + # Optional, defaults to sample content + build_args: | + ENV=build + ### Usually a bad idea / not recommended diff --git a/action.yml b/action.yml index adabc28..f670bad 100644 --- a/action.yml +++ b/action.yml @@ -25,6 +25,8 @@ inputs: description: Build context, not required for self-contained package/default directory build_file: description: Dockerfile with path, not required for self-contained package/default directory + build_args: + description: A list of build-time variables, not required ### Usually a bad idea / not recommended diff_branch: @@ -67,6 +69,13 @@ runs: echo "build_file=${{ inputs.build_file }}" >> $GITHUB_OUTPUT fi + # Use inputs.build_args unless an override has been provided + if [ -z ${{ inputs.build_args }} ]; then + echo "build_arguments=BUILDKIT_INLINE_CACHE=1" >> $GITHUB_OUTPUT + else + echo "build_arguments=${{ inputs.build_args }}" >> $GITHUB_OUTPUT + fi + # Bug - Docker build hates images with capital letters TAGS=$( echo "ghcr.io/${{ github.repository }}/${{ inputs.package }}:${{ inputs.tag }}" | tr '[:upper:]' '[:lower:]' ) echo "tags=${TAGS}" >> $GITHUB_OUTPUT @@ -156,6 +165,7 @@ runs: tags: ${{ steps.vars.outputs.tags }} cache-from: type=gha cache-to: type=gha,mode=max + build-args: ${{ steps.vars.outputs.build_arguments }} - name: Checkout Action repo to pass tests uses: actions/checkout@v3