Skip to content

Commit

Permalink
Avoid usage of ::set-output (#28)
Browse files Browse the repository at this point in the history
* 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
Mandrenkov authored Jan 9, 2023
1 parent 080cd2c commit 9971316
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 43 deletions.
55 changes: 15 additions & 40 deletions build-docker-image/action.yml
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 }}
2 changes: 1 addition & 1 deletion build-docker-images/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ inputs:
description: Docker build targets as a space-separated list (e.g., "daemon server").
required: true
docker-build-extra-args:
description: Docker build extra arguments.
description: Docker build extra arguments (e.g., "--build-arg DEBUG=false").
required: false

runs:
Expand Down
4 changes: 2 additions & 2 deletions generate-docker-image-tags/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ runs:
printf 'Cannot determine tags: Workflow must be triggered by "push", "pull_request", or "release" event.' && exit 1
fi
printf "::set-output name=branch::$BRANCH"
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
- id: get-tags
shell: bash
Expand Down Expand Up @@ -95,4 +95,4 @@ runs:
done <<< "$ids"
fi
printf "::set-output name=tags::$TAGS"
echo "tags=$TAGS" >> $GITHUB_OUTPUT

0 comments on commit 9971316

Please sign in to comment.