Skip to content

Release v0.1.1

Release v0.1.1 #2

Workflow file for this run

---
name: publish
on:
push:
branches-ignore:
- '*'
tags:
- 'v[0-9]*'
jobs:
publish:
env:
IMAGE_NAME: openshift-user-reaper
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@master
- name: Get the version
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/v0.1.2" or "refs/tags/v0.1.2-1"
# To determine RELEASE, strip off the leading "refs/tags/"
RELEASE=${GITHUB_REF#refs/tags/}
# 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.REGISTRY_REPOSITORY }}/${{ env.IMAGE_NAME }}:latest'
"${{ secrets.REGISTRY_URI }}/${{ secrets.REGISTRY_REPOSITORY }}/${{ env.IMAGE_NAME }}:${VERSION%.*}"
"${{ secrets.REGISTRY_URI }}/${{ secrets.REGISTRY_REPOSITORY }}/${{ env.IMAGE_NAME }}:${VERSION}"
)
# Set IMAGE_TAGS output for use in next step
( IFS=$','; echo "::set-output name=IMAGE_TAGS::${IMAGE_TAGS[*]}" )
fi
# Read version from helm/Chart.yaml
HELM_CHART_VERSION=$(sed -nr 's/^appVersion: (.*)/\1/p' helm/Chart.yaml)
if [[ "v${HELM_CHART_VERSION}" != "${VERSION}" ]]; then
echo "Helm chart version does not match tag!"
exit 1
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
if: steps.image_tags.outputs.IMAGE_TAGS
- name: Login to Image Registry
uses: docker/login-action@v1
if: steps.image_tags.outputs.IMAGE_TAGS
with:
registry: ${{ secrets.REGISTRY_URI }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and publish image to Quay
uses: docker/build-push-action@v2
if: steps.image_tags.outputs.IMAGE_TAGS
with:
file: Dockerfile
push: true
tags: ${{ steps.image_tags.outputs.IMAGE_TAGS }}