-
Notifications
You must be signed in to change notification settings - Fork 12
102 lines (91 loc) · 3.04 KB
/
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
name: publish
on:
push:
branches-ignore:
- '*'
tags:
- 'v[0-9]*'
jobs:
publish:
env:
IMAGE_NAME: anarchy
OPERATOR_IMAGE_NAME: anarchy-operator
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Set 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/v0.1.2" or "refs/tags/v0.1.2-1"
# To determine RELEASE, strip off the leading "refs/tags/"
RELEASE=${GITHUB_REF#refs/tags/v}
# To determine VERSION, strip off any release number suffix
VERSION=${RELEASE/-*/}
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
# 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,v1.2,v1.2.3
echo "IMAGE_TAGS=latest v${VERSION%.*} v${VERSION}" >> $GITHUB_OUTPUT
fi
# Read version from helm/Chart.yaml
HELM_CHART_VERSION=$(sed -nr 's/^appVersion: (.*)/\1/p' helm/Chart.yaml)
if [[ "${HELM_CHART_VERSION}" != "${VERSION}" ]]; then
echo "Helm chart version does not match tag!"
exit 1
fi
- name: Buildah Action
id: buildah-build
if: steps.image_tags.outputs.IMAGE_TAGS
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: ${{ steps.image_tags.outputs.IMAGE_TAGS }}
containerfiles: Dockerfile
- name: Push image to registry
id: push-to-registry
if: steps.image_tags.outputs.IMAGE_TAGS
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.buildah-build.outputs.image }}
tags: ${{ steps.buildah-build.outputs.tags }}
registry: ${{ vars.IMAGE_REGISTRY }}/${{ vars.IMAGE_REPOSITORY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
publish-helm-charts:
needs: publish
env:
IMAGE_NAME: anarchy
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Checkout gh-pages
uses: actions/checkout@v3
with:
ref: gh-pages
path: gh-pages
- name: Configure Helm
uses: azure/setup-helm@v1
with:
version: latest
- name: Package Helm Chart
run: |
helm dep up helm/
helm package helm/
mv ${{ env.IMAGE_NAME }}-*.tgz gh-pages
helm repo index --url https://redhat-cop.github.io/${{ env.IMAGE_NAME }} gh-pages
- name: Push Changes to GH Pages
run: |
cd gh-pages
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git add .
git commit -m "Updating Helm Chart Repository"
git push