From 3d17cbe7e2ab5aab3a3a74d7a24daeb17486c7a2 Mon Sep 17 00:00:00 2001 From: Stefan Negru Date: Wed, 16 Nov 2022 14:19:26 +0200 Subject: [PATCH] refactor for deprecated set-output gh action --- .github/workflows/publish.yml | 41 ++++++++++++++--------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 48eac6d5..64a62ef2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,6 +5,8 @@ on: types: [published] push: branches: [master] + tags: + - 'v*' jobs: push_to_registry: @@ -14,27 +16,6 @@ jobs: - name: Check out the repo uses: actions/checkout@v3 - - name: Prepare - id: prep - run: | - DOCKER_IMAGE=cscfi/beacon-python - DOCKER_IMAGE_DATA=cscfi/beacon-python - VERSION=edge - if [[ $GITHUB_REF == refs/tags/* ]]; then - VERSION=${GITHUB_REF#refs/tags/} - elif [[ $GITHUB_REF == refs/heads/* ]]; then - BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') - if [[ $BRANCH == master ]]; then - VERSION=latest - fi - fi - TAGS="${DOCKER_IMAGE}:${VERSION}" - TAGS_DATA="${DOCKER_IMAGE_DATA}:${VERSION}" - echo ::set-output name=version::${VERSION} - echo ::set-output name=tags::${TAGS} - echo ::set-output name=tagsData::${TAGS_DATA} - echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -44,6 +25,16 @@ jobs: with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: cscfi/beacon-python + tags: | + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} + type=raw,value=stage,enable=${{ github.ref == format('refs/heads/{0}', 'dev') }} + type=ref,event=tag - name: Build and push uses: docker/build-push-action@v3 @@ -51,12 +42,12 @@ jobs: context: . file: ./Dockerfile push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.prep.outputs.tags }} + tags: ${{ steps.meta.outputs.tags }} cache-from: type=registry,ref=cscfi/beacon-python:latest cache-to: type=inline labels: | org.opencontainers.image.source=${{ github.event.repository.clone_url }} - org.opencontainers.image.created=${{ steps.prep.outputs.created }} + org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ') org.opencontainers.image.revision=${{ github.sha }} - name: Build and push dataloader @@ -67,10 +58,10 @@ jobs: context: . file: ./Dockerfile push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.prep.outputs.tagsData }} + tags: ${{ steps.meta.outputs.tags }} cache-from: type=registry,ref=cscfi/beacon-dataloader:latest cache-to: type=inline labels: | org.opencontainers.image.source=${{ github.event.repository.clone_url }} - org.opencontainers.image.created=${{ steps.prep.outputs.created }} + org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ') org.opencontainers.image.revision=${{ github.sha }}