-
Notifications
You must be signed in to change notification settings - Fork 23
78 lines (72 loc) · 3.29 KB
/
catalog-status-publish.yaml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
name: catalog-status-publish
on:
push:
branches-ignore:
- "*"
tags:
- "catalog-status-v[0-9]*"
jobs:
publish:
env:
IMAGE_NAME: babylon-catalog-status
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Get image tags
id: image_tags
run: |
# Version is a semantic version tag or semantic version with release number
# GITHUB_REF will be of the form "refs/tags/admin-v0.1.2" or "refs/tags/admin-v0.1.2-1"
# To determine RELEASE, strip off the leading "refs/tags/"
RELEASE=${GITHUB_REF#refs/tags/catalog-status-}
# To determine VERSION, strip off any release number suffix
VERSION=${RELEASE/-*/}
echo "::set-output name=RELEASE::${RELEASE}"
echo "::set-output name=VERSION::${VERSION}"
# Only build image if version tag without release number
# Releases indicate a change in the repository that should not trigger a new build.
if [[ "${VERSION}" == "${RELEASE}" ]]; then
# Publish to latest, minor, and patch tags
# Ex: latest,v0.1.2,v0.1
IMAGE_TAGS=(
'${{ secrets.REGISTRY_URI }}/${{ secrets.GPTE_REGISTRY_REPOSITORY }}/${{ env.IMAGE_NAME }}:latest'
"${{ secrets.REGISTRY_URI }}/${{ secrets.GPTE_REGISTRY_REPOSITORY }}/${{ env.IMAGE_NAME }}:${VERSION%.*}"
"${{ secrets.REGISTRY_URI }}/${{ secrets.GPTE_REGISTRY_REPOSITORY }}/${{ env.IMAGE_NAME }}:${VERSION}"
)
IMAGE_TAGS_PARTNERS=(
'${{ secrets.REGISTRY_URI }}/${{ secrets.GPTE_REGISTRY_REPOSITORY }}/${{ env.IMAGE_NAME }}-partners:latest'
"${{ secrets.REGISTRY_URI }}/${{ secrets.GPTE_REGISTRY_REPOSITORY }}/${{ env.IMAGE_NAME }}-partners:${VERSION%.*}"
"${{ secrets.REGISTRY_URI }}/${{ secrets.GPTE_REGISTRY_REPOSITORY }}/${{ env.IMAGE_NAME }}-partners:${VERSION}"
)
# Set IMAGE_TAGS and IMAGE_TAGS_PARTNERS output for use in next step
( IFS=$','; echo "::set-output name=IMAGE_TAGS::${IMAGE_TAGS[*]}" )
( IFS=$','; echo "::set-output name=IMAGE_TAGS_PARTNERS::${IMAGE_TAGS_PARTNERS[*]}" )
fi
- name: Set up buildx
uses: docker/setup-buildx-action@v1
if: steps.image_tags.outputs.IMAGE_TAGS
- name: Login to redhat.io registry
uses: docker/login-action@v1
if: steps.image_tags.outputs.IMAGE_TAGS
with:
registry: ${{ secrets.REDHAT_REGISTRY_URI }}
username: ${{ secrets.REDHAT_REGISTRY_USERNAME }}
password: ${{ secrets.REDHAT_REGISTRY_PASSWORD }}
- name: Login to quay.io registry
uses: docker/login-action@v1
if: steps.image_tags.outputs.IMAGE_TAGS
with:
registry: ${{ secrets.REGISTRY_URI }}
username: ${{ secrets.GPTE_REGISTRY_USERNAME }}
password: ${{ secrets.GPTE_REGISTRY_PASSWORD }}
- name: Build and publish image
uses: docker/build-push-action@v2
if: steps.image_tags.outputs.IMAGE_TAGS
with:
registry: ${{ secrets.REGISTRY_URI }}
context: catalog/status
file: catalog/status/Dockerfile
push: true
tags: ${{ steps.image_tags.outputs.IMAGE_TAGS }}