Skip to content

Commit

Permalink
Support optional target and build-args in build action
Browse files Browse the repository at this point in the history
  • Loading branch information
tcjennings committed Dec 17, 2024
1 parent bbcadb8 commit 949340d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ To automatically set that, the above example uses the context variable `${{ gith

- `platforms` (list, optional) List of target platform for build.

- `target` (string, optional) the name of a build stage in the Dockerfile to target for the image. This allows multiple images
built from a single Dockerfile, e.g., "runtime-A" and "runtime-B".

- `build-args` (string, optional) A list of build-arguments as newline-delimited `arg=value` string pairs. These may be
specified in the Dockerfile as `ARG` statements.

- `additional-tags` (list[string], optional) A list of additional tags to be added to the built image.

### Outputs

- `fully_qualified_image_digest` (string) A complete, unique, and immutable identifier for the built image,
Expand Down
13 changes: 13 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ inputs:
platforms:
description: "List of target platforms for build"
required: false
target:
description: "Name of target stage to build"
required: false
build-args:
description: "List of build-time variables"
required: false
additional-tags:
description: "List of additional tags to add to built image"
required: false
default: []
outputs:
tag:
description: "The tag of the Docker image that was built."
Expand Down Expand Up @@ -61,9 +71,12 @@ runs:
with:
context: "${{ inputs.context }}"
file: "${{ inputs.dockerfile }}"
build-args: "${{ inputs.build-args }}"
target: "${{ inputs.target }}"
push: ${{ fromJSON(inputs.push) == true }}
platforms: ${{ inputs.platforms }}
tags: |
ghcr.io/${{ inputs.image }}:${{ steps.tag.outputs.tag }}
${{ join('\n', fromJSON(inputs.additional-tags) }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit 949340d

Please sign in to comment.