Skip to content

Commit 9971316

Browse files
authored
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
1 parent 080cd2c commit 9971316

File tree

3 files changed

+18
-43
lines changed

3 files changed

+18
-43
lines changed

build-docker-image/action.yml

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,30 @@
11
name: Build Docker Image
2-
description: Build a local Docker image using buildkit
2+
description: Builds a Docker image (with BuildKit enabled).
33

44
inputs:
55
path:
6-
description: Path to Docker build context
6+
description: Docker build context path (e.g., ".").
77
required: true
88
target:
9-
description: Docker build target
9+
description: Docker build target (e.g., "server").
1010
required: true
1111
tag:
12-
description: Local tag for Docker image
13-
required: false
14-
docker-args:
15-
description: Extra arguments to docker build
12+
description: Docker build image tag (e.g., "server-production").
13+
required: true
14+
docker-build-extra-args:
15+
description: Docker build extra arguments (e.g., "--build-arg DEBUG=false").
1616
required: false
1717

18-
outputs:
19-
image-id:
20-
description: Docker image ID
21-
value: ${{ steps.get-image-id.outputs.id }}
22-
2318
runs:
2419
using: composite
2520
steps:
26-
- name: Generate ID file path
27-
id: id-file
28-
shell: bash
29-
run: printf "::set-output name=path::%s/iidfile_%s_$RANDOM" ${{ runner.temp }} $(date +%s)
30-
31-
- name: Build image
32-
shell: bash
21+
- shell: bash
3322
env:
3423
DOCKER_BUILDKIT: 1
35-
run: |
36-
docker build \
37-
--iidfile=${{ steps.id-file.outputs.path }} \
38-
--target=${{ inputs.target }} \
39-
--build-arg COMMIT_SHA=$(git rev-parse --short HEAD) \
40-
${{ inputs.docker-args }} ${{ inputs.path }}
41-
42-
- name: Get image ID
43-
id: get-image-id
44-
shell: bash
45-
run: |
46-
printf "::set-output name=id::%s" $(cat ${{ steps.id-file.outputs.path }})
47-
rm -f ${{ steps.id-file.outputs.path }}
48-
49-
- name: Tag image
50-
shell: bash
51-
run: |
52-
if [ -n "${{ inputs.tag }}" ]
53-
then
54-
docker tag ${{ steps.get-image-id.outputs.id }} ${{ inputs.tag }}
55-
fi
24+
run: >
25+
docker build
26+
--ssh default
27+
--tag ${{ inputs.tag }}
28+
--target ${{ inputs.target }}
29+
--build-arg COMMIT_SHA=${{ github.sha }}
30+
${{ inputs.docker-build-extra-args }} ${{ inputs.path }}

build-docker-images/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ inputs:
1111
description: Docker build targets as a space-separated list (e.g., "daemon server").
1212
required: true
1313
docker-build-extra-args:
14-
description: Docker build extra arguments.
14+
description: Docker build extra arguments (e.g., "--build-arg DEBUG=false").
1515
required: false
1616

1717
runs:

generate-docker-image-tags/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ runs:
4545
printf 'Cannot determine tags: Workflow must be triggered by "push", "pull_request", or "release" event.' && exit 1
4646
fi
4747
48-
printf "::set-output name=branch::$BRANCH"
48+
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
4949
5050
- id: get-tags
5151
shell: bash
@@ -95,4 +95,4 @@ runs:
9595
done <<< "$ids"
9696
fi
9797
98-
printf "::set-output name=tags::$TAGS"
98+
echo "tags=$TAGS" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)