Skip to content

Commit 041109a

Browse files
authored
ci: use docker/metadata-action to gather tags/labels (#3998)
1 parent b76a83a commit 041109a

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

.github/workflows/release.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,27 @@ jobs:
4444
with:
4545
subject-path: "${{ github.workspace }}/build/aws/elastic-apm-node-lambda-layer-*.zip"
4646

47-
- id: docker-vars
48-
name: Set up docker variables
49-
run: |-
50-
if [ "${{ startsWith(github.ref, 'refs/tags') }}" == "false" ] ; then
51-
# for testing purposes
52-
echo "tag=test" >> "${GITHUB_OUTPUT}"
53-
echo "latest=test-latest" >> "${GITHUB_OUTPUT}"
54-
else
55-
# version without v prefix (e.g. 1.2.3)
56-
echo "tag=${GITHUB_REF_NAME/v/}" >> "${GITHUB_OUTPUT}"
57-
echo "latest=latest" >> "${GITHUB_OUTPUT}"
58-
fi
47+
- name: Extract metadata (tags, labels)
48+
id: docker-meta
49+
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
50+
with:
51+
images: ${{ env.DOCKER_IMAGE_NAME }}
52+
flavor: |
53+
latest=auto
54+
tags: |
55+
# "1.2.3" and "latest" Docker tags on push of git tag "v1.2.3"
56+
type=semver,pattern={{version}}
57+
# "edge" Docker tag on git push to default branch
58+
type=edge
5959
6060
- name: Build and Push Docker Image
6161
id: docker-push
62-
uses: docker/[email protected]
62+
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
6363
with:
6464
context: .
6565
push: true
66-
tags: |
67-
${{ env.DOCKER_IMAGE_NAME }}:${{ steps.docker-vars.outputs.tag }}
68-
${{ env.DOCKER_IMAGE_NAME }}:${{ steps.docker-vars.outputs.latest }}
66+
tags: ${{ steps.docker-meta.outputs.tags }}
67+
labels: ${{ steps.docker-meta.outputs.labels }}
6968
build-args: |
7069
AGENT_DIR=/build/dist/nodejs
7170

0 commit comments

Comments
 (0)