Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

refactor for deprecated set-output gh action #344

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 16 additions & 25 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
types: [published]
push:
branches: [master]
tags:
- 'v*'

jobs:
push_to_registry:
Expand All @@ -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

Expand All @@ -44,19 +25,29 @@ 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
with:
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
Expand All @@ -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 }}