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

Commit e0e9a96

Browse files
authored
Merge pull request #345 from CSCfi/dev
publish action to master
2 parents 76f19ec + aaf8b28 commit e0e9a96

1 file changed

Lines changed: 16 additions & 25 deletions

File tree

.github/workflows/publish.yml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
types: [published]
66
push:
77
branches: [master]
8+
tags:
9+
- 'v*'
810

911
jobs:
1012
push_to_registry:
@@ -14,27 +16,6 @@ jobs:
1416
- name: Check out the repo
1517
uses: actions/checkout@v3
1618

17-
- name: Prepare
18-
id: prep
19-
run: |
20-
DOCKER_IMAGE=cscfi/beacon-python
21-
DOCKER_IMAGE_DATA=cscfi/beacon-python
22-
VERSION=edge
23-
if [[ $GITHUB_REF == refs/tags/* ]]; then
24-
VERSION=${GITHUB_REF#refs/tags/}
25-
elif [[ $GITHUB_REF == refs/heads/* ]]; then
26-
BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
27-
if [[ $BRANCH == master ]]; then
28-
VERSION=latest
29-
fi
30-
fi
31-
TAGS="${DOCKER_IMAGE}:${VERSION}"
32-
TAGS_DATA="${DOCKER_IMAGE_DATA}:${VERSION}"
33-
echo ::set-output name=version::${VERSION}
34-
echo ::set-output name=tags::${TAGS}
35-
echo ::set-output name=tagsData::${TAGS_DATA}
36-
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
37-
3819
- name: Set up Docker Buildx
3920
uses: docker/setup-buildx-action@v2
4021

@@ -44,19 +25,29 @@ jobs:
4425
with:
4526
username: ${{ secrets.DOCKER_USERNAME }}
4627
password: ${{ secrets.DOCKER_PASSWORD }}
28+
29+
- name: Extract metadata (tags, labels) for Docker
30+
id: meta
31+
uses: docker/metadata-action@v4
32+
with:
33+
images: cscfi/beacon-python
34+
tags: |
35+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
36+
type=raw,value=stage,enable=${{ github.ref == format('refs/heads/{0}', 'dev') }}
37+
type=ref,event=tag
4738
4839
- name: Build and push
4940
uses: docker/build-push-action@v3
5041
with:
5142
context: .
5243
file: ./Dockerfile
5344
push: ${{ github.event_name != 'pull_request' }}
54-
tags: ${{ steps.prep.outputs.tags }}
45+
tags: ${{ steps.meta.outputs.tags }}
5546
cache-from: type=registry,ref=cscfi/beacon-python:latest
5647
cache-to: type=inline
5748
labels: |
5849
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
59-
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
50+
org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
6051
org.opencontainers.image.revision=${{ github.sha }}
6152
6253
- name: Build and push dataloader
@@ -67,10 +58,10 @@ jobs:
6758
context: .
6859
file: ./Dockerfile
6960
push: ${{ github.event_name != 'pull_request' }}
70-
tags: ${{ steps.prep.outputs.tagsData }}
61+
tags: ${{ steps.meta.outputs.tags }}
7162
cache-from: type=registry,ref=cscfi/beacon-dataloader:latest
7263
cache-to: type=inline
7364
labels: |
7465
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
75-
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
66+
org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
7667
org.opencontainers.image.revision=${{ github.sha }}

0 commit comments

Comments
 (0)