-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Simplify 'Build Docker Image' action and require the `tag` input * Add example to extra arguments input * Remove usage of `set-output` in GDIT Action
- Loading branch information
1 parent
080cd2c
commit 9971316
Showing
3 changed files
with
18 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,30 @@ | ||
name: Build Docker Image | ||
description: Build a local Docker image using buildkit | ||
description: Builds a Docker image (with BuildKit enabled). | ||
|
||
inputs: | ||
path: | ||
description: Path to Docker build context | ||
description: Docker build context path (e.g., "."). | ||
required: true | ||
target: | ||
description: Docker build target | ||
description: Docker build target (e.g., "server"). | ||
required: true | ||
tag: | ||
description: Local tag for Docker image | ||
required: false | ||
docker-args: | ||
description: Extra arguments to docker build | ||
description: Docker build image tag (e.g., "server-production"). | ||
required: true | ||
docker-build-extra-args: | ||
description: Docker build extra arguments (e.g., "--build-arg DEBUG=false"). | ||
required: false | ||
|
||
outputs: | ||
image-id: | ||
description: Docker image ID | ||
value: ${{ steps.get-image-id.outputs.id }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Generate ID file path | ||
id: id-file | ||
shell: bash | ||
run: printf "::set-output name=path::%s/iidfile_%s_$RANDOM" ${{ runner.temp }} $(date +%s) | ||
|
||
- name: Build image | ||
shell: bash | ||
- shell: bash | ||
env: | ||
DOCKER_BUILDKIT: 1 | ||
run: | | ||
docker build \ | ||
--iidfile=${{ steps.id-file.outputs.path }} \ | ||
--target=${{ inputs.target }} \ | ||
--build-arg COMMIT_SHA=$(git rev-parse --short HEAD) \ | ||
${{ inputs.docker-args }} ${{ inputs.path }} | ||
- name: Get image ID | ||
id: get-image-id | ||
shell: bash | ||
run: | | ||
printf "::set-output name=id::%s" $(cat ${{ steps.id-file.outputs.path }}) | ||
rm -f ${{ steps.id-file.outputs.path }} | ||
- name: Tag image | ||
shell: bash | ||
run: | | ||
if [ -n "${{ inputs.tag }}" ] | ||
then | ||
docker tag ${{ steps.get-image-id.outputs.id }} ${{ inputs.tag }} | ||
fi | ||
run: > | ||
docker build | ||
--ssh default | ||
--tag ${{ inputs.tag }} | ||
--target ${{ inputs.target }} | ||
--build-arg COMMIT_SHA=${{ github.sha }} | ||
${{ inputs.docker-build-extra-args }} ${{ inputs.path }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters