From 9971316c5e40e741413db89eafc85a1db9557001 Mon Sep 17 00:00:00 2001 From: Mikhail Andrenkov Date: Mon, 9 Jan 2023 16:43:50 -0500 Subject: [PATCH] Avoid usage of `::set-output` (#28) * Simplify 'Build Docker Image' action and require the `tag` input * Add example to extra arguments input * Remove usage of `set-output` in GDIT Action --- build-docker-image/action.yml | 55 ++++++++------------------- build-docker-images/action.yml | 2 +- generate-docker-image-tags/action.yml | 4 +- 3 files changed, 18 insertions(+), 43 deletions(-) diff --git a/build-docker-image/action.yml b/build-docker-image/action.yml index 21d86fa..74802d7 100644 --- a/build-docker-image/action.yml +++ b/build-docker-image/action.yml @@ -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 }} diff --git a/build-docker-images/action.yml b/build-docker-images/action.yml index acc5115..3d79d68 100644 --- a/build-docker-images/action.yml +++ b/build-docker-images/action.yml @@ -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: diff --git a/generate-docker-image-tags/action.yml b/generate-docker-image-tags/action.yml index 284de8e..65a8b2d 100644 --- a/generate-docker-image-tags/action.yml +++ b/generate-docker-image-tags/action.yml @@ -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 @@ -95,4 +95,4 @@ runs: done <<< "$ids" fi - printf "::set-output name=tags::$TAGS" + echo "tags=$TAGS" >> $GITHUB_OUTPUT