From bbede9ec36c4febd3ad6d8bb73bd0df581acee52 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 29 Apr 2024 14:07:24 +0200 Subject: [PATCH 1/4] ci: use docker/metadata-action to gather tags/labels --- .github/workflows/release.yml | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 47da268900..b655b84206 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,28 +44,23 @@ jobs: with: subject-path: "${{ github.workspace }}/build/aws/elastic-apm-node-lambda-layer-*.zip" - - id: docker-vars - name: Set up docker variables - run: |- - if [ "${{ startsWith(github.ref, 'refs/tags') }}" == "false" ] ; then - # for testing purposes - echo "tag=test" >> "${GITHUB_OUTPUT}" - echo "latest=test-latest" >> "${GITHUB_OUTPUT}" - else - # version without v prefix (e.g. 1.2.3) - echo "tag=${GITHUB_REF_NAME/v/}" >> "${GITHUB_OUTPUT}" - echo "latest=latest" >> "${GITHUB_OUTPUT}" - fi + - name: Extract metadata (tags, labels) + id: docker-meta + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 + with: + images: ${{ env.DOCKER_IMAGE_NAME }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=ref,event=tag,prefix=,suffix= - name: Build and Push Docker Image id: docker-push - uses: docker/build-push-action@v5.3.0 + uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 with: context: . push: true - tags: | - ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.docker-vars.outputs.tag }} - ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.docker-vars.outputs.latest }} + tags: ${{ steps.docker-meta.outputs.tags }} + labels: ${{ steps.docker-meta.outputs.labels }} build-args: | AGENT_DIR=/build/dist/nodejs From 8640a164529654d9140137b5f9339e5e128edd28 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 29 Apr 2024 14:11:26 +0200 Subject: [PATCH 2/4] add prefix --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b655b84206..89c5bf8fa7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,7 +50,7 @@ jobs: with: images: ${{ env.DOCKER_IMAGE_NAME }} tags: | - type=raw,value=latest,enable={{is_default_branch}} + type=raw,value=latest,prefix=test-,enable={{is_default_branch}} type=ref,event=tag,prefix=,suffix= - name: Build and Push Docker Image From a4350d6382af450a7c17141f7029e9e1bf6897f4 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 29 Apr 2024 15:26:58 +0200 Subject: [PATCH 3/4] Update .github/workflows/release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 89c5bf8fa7..5f06e603a6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,7 +51,7 @@ jobs: images: ${{ env.DOCKER_IMAGE_NAME }} tags: | type=raw,value=latest,prefix=test-,enable={{is_default_branch}} - type=ref,event=tag,prefix=,suffix= + type=semver,pattern={{version}} - name: Build and Push Docker Image id: docker-push From 479d97b8c4e04cda5db3237a323cea5c7c1324a3 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Fri, 10 May 2024 09:26:46 +0200 Subject: [PATCH 4/4] as discussed --- .github/workflows/release.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5f06e603a6..942b6e4eeb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,9 +49,13 @@ jobs: uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 with: images: ${{ env.DOCKER_IMAGE_NAME }} + flavor: | + latest=auto tags: | - type=raw,value=latest,prefix=test-,enable={{is_default_branch}} + # "1.2.3" and "latest" Docker tags on push of git tag "v1.2.3" type=semver,pattern={{version}} + # "edge" Docker tag on git push to default branch + type=edge - name: Build and Push Docker Image id: docker-push