Skip to content

Commit

Permalink
feat: adding build args optional parameter (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj authored Jul 27, 2023
1 parent 5821d79 commit da8f1ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit da8f1ca

Please sign in to comment.