@@ -32,47 +32,42 @@ runs:
32
32
shell : bash
33
33
env :
34
34
GITHUB_TOKEN : ${{ inputs.github_token }}
35
+ DOCKER_BUILDKIT : 1
36
+ DOCKER_IO_TOKEN : ${{ inputs.docker_io_token }}
37
+
35
38
run : |
39
+ echo "::group::Logging into the GitHub Container registry (ghcr.io) ..."
36
40
echo "${GITHUB_TOKEN}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
41
+ echo "::endgroup::"
37
42
38
- - name : Set commit tag and image name
39
- shell : bash
40
- run : |
43
+ echo "::group::Set commit tag and image name"
41
44
if [ "${{ github.event_name }}" = "release" ]; then
42
45
export COMMIT_TAG=${GITHUB_REF:10}
43
- # export COMMIT_TAG=v2.3.0 # debug
44
- echo "COMMIT_TAG=${COMMIT_TAG//v/}" >> $GITHUB_ENV # remove "v" suffix
46
+ export COMMIT_TAG=${COMMIT_TAG//v/}
45
47
else
46
- echo " COMMIT_TAG=latest" >> $GITHUB_ENV
48
+ export COMMIT_TAG=latest
47
49
fi
48
50
49
- - name : " Build the Docker image"
50
- shell : bash
51
- run : |
52
- # expand commands
53
- set -x
54
-
55
- docker -v
51
+ echo "Tagging with ${COMMIT_TAG}"
52
+ echo "::endgroup::"
56
53
57
54
export BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
58
55
export GITHUB_URL=https://github.com/${{ github.repository }}
59
56
60
- echo
61
- echo "Building the Docker image: ${{ inputs.repository }}/${{ inputs.image_name }}:${{ env.COMMIT_TAG }} ..."
62
- echo
57
+ echo "::group::Building the Docker image: ${{ inputs.repository }}/${{ inputs.image_name }}:${COMMIT_TAG} ..."
63
58
64
59
# https://docs.docker.com/develop/develop-images/build_enhancements/
65
60
# https://docs.docker.com/engine/reference/commandline/build/#specifying-external-cache-sources
66
- DOCKER_BUILDKIT=1 \
67
- docker build . \
61
+ docker build . \
62
+ --quiet \
68
63
--cache-from ${{ inputs.repository }}/${{ inputs.image_name }}:latest \
69
64
--build-arg BUILDKIT_INLINE_CACHE=1 \
70
65
\
71
66
--build-arg BUILD_DATE=${BUILD_DATE} \
72
67
--build-arg GITHUB_SHA=${GITHUB_SHA} \
73
68
\
74
- --tag ${{ inputs.repository }}/${{ inputs.image_name }}:${{ env. COMMIT_TAG } } \
75
- --tag docker.io/${{ inputs.image_name }}:${{ env. COMMIT_TAG } } \
69
+ --tag ${{ inputs.repository }}/${{ inputs.image_name }}:${COMMIT_TAG} \
70
+ --tag docker.io/${{ inputs.image_name }}:${COMMIT_TAG} \
76
71
\
77
72
--label org.label-schema.build-date=${BUILD_DATE} \
78
73
--label org.label-schema.vcs-url=${GITHUB_URL} \
@@ -81,44 +76,37 @@ runs:
81
76
--label org.opencontainers.image.created=${BUILD_DATE} \
82
77
--label org.opencontainers.image.source=${GITHUB_URL} \
83
78
--label org.opencontainers.image.revision=${GITHUB_SHA}
84
-
85
- echo
86
- echo "Inspecting the image ..."
87
- echo
88
79
80
+ echo "::endgroup::"
81
+
82
+ echo "::group::Inspecting the image ..."
89
83
docker images
90
- docker image inspect ${{ inputs.repository }}/${{ inputs.image_name }}:${{ env.COMMIT_TAG }} | jq '.[].Config.Labels'
91
84
92
- - name : " Push the Docker image to ghcr.io"
93
- shell : bash
94
- run : |
95
- # expand commands
85
+ echo "Labels:"
86
+ docker image inspect ${{ inputs.repository }}/${{ inputs.image_name }}:${COMMIT_TAG} | jq '.[].Config.Labels'
87
+
88
+ echo "Env variables:"
89
+ docker image inspect ${{ inputs.repository }}/${{ inputs.image_name }}:${COMMIT_TAG} | jq '.[].Config.Env'
90
+
91
+ echo "::endgroup::"
92
+
93
+ echo "::group::Pushing the Docker image to ${{ inputs.repository }} ..."
94
+
96
95
set -x
97
-
98
- echo
99
- echo "Pushing the Docker image to ghcr.io ..."
100
- echo
96
+ docker push --quiet ${{ inputs.repository }}/${{ inputs.image_name }}:${COMMIT_TAG}
97
+ set +x
101
98
102
- docker push ${{ inputs.repository }}/${{ inputs.image_name }}:${{ env.COMMIT_TAG }}
99
+ echo "::endgroup::"
103
100
104
- - name : " Push the Docker image to docker.io"
105
- shell : bash
106
- env :
107
- DOCKER_TOKEN : ${{ inputs.docker_io_token }}
108
- run : |
109
- if [ -z "${DOCKER_TOKEN}" ]; then
110
- echo
111
- echo "NOT pushing the Docker image to docker.io ... Provide 'docker_io_token' if needed."
112
- echo
101
+ if [ -z "${DOCKER_IO_TOKEN}" ]; then
102
+ echo "::warning::NOT pushing the Docker image to docker.io ... Provide 'docker_io_token' if needed."
113
103
else
114
- # expand commands
115
- set -x
104
+ echo "::group::Pushing the Docker image to docker.io ..."
105
+ echo "${DOCKER_IO_TOKEN}" | docker login docker.io -u "${{ github.actor }}" --password-stdin
116
106
117
- echo
118
- echo "Pushing the Docker image to docker.io ..."
119
- echo
120
-
121
- echo "${DOCKER_TOKEN}" | docker login docker.io -u "${{ github.actor }}" --password-stdin
107
+ set -x
108
+ docker push --quiet docker.io/${{ inputs.image_name }}:${COMMIT_TAG}
109
+ set +x
122
110
123
- docker push docker.io/${{ inputs.image_name }}:${{ env.COMMIT_TAG }}
111
+ echo "::endgroup::"
124
112
fi
0 commit comments