Skip to content

Commit 880c594

Browse files
authored
ci: use docker/metadata-action to gather tags/labels (#2033)
1 parent 52e9c1b commit 880c594

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

.github/workflows/release.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -123,31 +123,29 @@ jobs:
123123
url: ${{ secrets.VAULT_ADDR }}
124124
roleId: ${{ secrets.VAULT_ROLE_ID }}
125125
secretId: ${{ secrets.VAULT_SECRET_ID }}
126+
126127
- uses: actions/download-artifact@v4
127128
with:
128129
name: build-distribution
129130
path: ./build
130-
- id: setup-docker
131-
name: Set up docker variables
132-
run: |-
133-
if [ "${{ startsWith(github.ref, 'refs/tags') }}" == "false" ] ; then
134-
# for testing purposes
135-
echo "tag=test" >> "${GITHUB_OUTPUT}"
136-
echo "latest=test-latest" >> "${GITHUB_OUTPUT}"
137-
else
138-
# version without v prefix (e.g. 1.2.3)
139-
echo "tag=${GITHUB_REF_NAME/v/}" >> "${GITHUB_OUTPUT}"
140-
echo "latest=latest" >> "${GITHUB_OUTPUT}"
141-
fi
131+
132+
- name: Extract metadata (tags, labels)
133+
id: docker-meta
134+
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
135+
with:
136+
images: ${{ env.DOCKER_IMAGE_NAME }}
137+
tags: |
138+
type=raw,value=latest,prefix=test-,enable={{is_default_branch}}
139+
type=semver,pattern={{version}}
140+
142141
- name: Build and push image
143142
id: push
144-
uses: docker/[email protected]
143+
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
145144
with:
146145
context: .
147146
push: true
148-
tags: |
149-
${{ env.DOCKER_IMAGE_NAME }}:${{ steps.setup-docker.outputs.tag }}
150-
${{ env.DOCKER_IMAGE_NAME }}:${{ steps.setup-docker.outputs.latest }}
147+
tags: ${{ steps.docker-meta.outputs.tags }}
148+
labels: ${{ steps.docker-meta.outputs.labels }}
151149
build-args: |
152150
AGENT_DIR=./build/dist/package/python
153151
@@ -156,7 +154,7 @@ jobs:
156154
with:
157155
subject-name: "${{ env.DOCKER_IMAGE_NAME }}"
158156
subject-digest: ${{ steps.push.outputs.digest }}
159-
push-to-registry: false
157+
push-to-registry: true
160158

161159
github-draft:
162160
permissions:

0 commit comments

Comments
 (0)