This repository has been archived by the owner on Aug 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (46 loc) · 1.99 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Publish to Docker Hub
env:
DOCKER_IMAGE: ghcr.io/elseu/sdu-oidc-jwt-provider
on:
push:
tags:
- "v*"
branches:
- master
- develop
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build docker image
run: docker build -t $DOCKER_IMAGE .
- name: Push to latest
if: github.ref == 'refs/heads/master'
run: docker tag $DOCKER_IMAGE $DOCKER_IMAGE:latest && docker push $DOCKER_IMAGE:latest
- name: Push to develop
if: github.ref == 'refs/heads/develop'
run: docker tag $DOCKER_IMAGE $DOCKER_IMAGE:next && docker push $DOCKER_IMAGE:next
- name: Push to versions
if: startsWith(github.ref, 'refs/tags/v')
run: |
VERSION_SUFFIX=$(echo ${GITHUB_REF/refs\/tags\/v/} | sed -E s/[^-]+//)
MAJOR_VERSION=$(echo ${GITHUB_REF/refs\/tags\/v/} | sed -E s/^\([0-9]+\).*$/\\1/ | sed -E s/-.*$//)
MINOR_VERSION=$(echo ${GITHUB_REF/refs\/tags\/v/} | sed -E s/^\([0-9]+\.[0-9]+\).*$/\\1/ | sed -E s/-.*$//)
FULL_VERSION=$(echo ${GITHUB_REF/refs\/tags\/v/} | sed -E s/^\([0-9]+\.[0-9]+\.[0-9]+\).*$/\\1/ | sed -E s/-.*$//)
if [ ! -z "$MAJOR_VERSION" ]; then
docker tag $DOCKER_IMAGE $DOCKER_IMAGE:$MAJOR_VERSION$VERSION_SUFFIX && docker push $DOCKER_IMAGE:$MAJOR_VERSION$VERSION_SUFFIX
fi
if [ ! -z "$MINOR_VERSION" ]; then
docker tag $DOCKER_IMAGE $DOCKER_IMAGE:$MINOR_VERSION$VERSION_SUFFIX && docker push $DOCKER_IMAGE:$MINOR_VERSION$VERSION_SUFFIX
fi
if [ ! -z "$FULL_VERSION" ]; then
docker tag $DOCKER_IMAGE $DOCKER_IMAGE:$FULL_VERSION$VERSION_SUFFIX && docker push $DOCKER_IMAGE:$FULL_VERSION$VERSION_SUFFIX
fi