-
Notifications
You must be signed in to change notification settings - Fork 4
94 lines (81 loc) · 3.35 KB
/
publish-chart.yml
File metadata and controls
94 lines (81 loc) · 3.35 KB
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
name: Release Helm Chart
on:
release:
types:
- published
push:
branches:
- main
tags:
- 'v*.*.*'
paths-ignore:
- 'docs/**'
- '**/*.md'
pull_request:
branches:
- main
paths-ignore:
- 'docs/**'
- '**/*.md'
types: [labeled, opened, synchronize, reopened]
jobs:
helm-chart:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: |
github.event_name == 'push' ||
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ok-to-charts')) ||
(github.event_name == 'release' && github.event.action == 'published')
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Helm
uses: azure/setup-helm@v5
with:
version: v3.16.2
- name: Determine chart version
id: chart_version
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
# Use SHA for main branch
CHART_VERSION="0.0.0-$(echo ${{ github.sha }} | cut -c1-7)"
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# Use tag version (strip 'v' prefix)
CHART_VERSION="${GITHUB_REF#refs/tags/v}"
else
# Use PR SHA for dry run
CHART_VERSION="0.0.0-$(echo ${{ github.sha }} | cut -c1-7)"
fi
echo "version=$CHART_VERSION" >> $GITHUB_OUTPUT
- name: Install Kustomize
run: |
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
mv kustomize /usr/local/bin
- name: Install yq
run: |
curl -fsSL https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -o /usr/local/bin/yq && chmod a+x /usr/local/bin/yq
- name: Set container image repository and tag
run: |
IMAGE_TAG=sha-$(echo ${{ github.sha }} | cut -c1-7)
yq -i '.controllerManager.manager.image.repository = "ghcr.io/ironcore-dev/boot-operator"' dist/chart/values.yaml
yq -i '.controllerManager.manager.image.tag = "'$IMAGE_TAG'"' dist/chart/values.yaml
- name: Package Helm chart with crds folder in template
run: |
helm package dist/chart --version ${{ steps.chart_version.outputs.version }}-crds
- name: Prepare CRDs folder
run: |
mkdir -p dist/chart/crds
kustomize build config/default | yq ea 'select(.kind == "CustomResourceDefinition")' > dist/chart/crds/crds.yaml
rm -rf dist/chart/templates/crd
- name: Package Helm chart with removed crds folder from template folder
run: |
helm package dist/chart --version ${{ steps.chart_version.outputs.version }}
- name: Log in to GitHub Container Registry
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push Helm chart to GHCR
run: |
helm push boot-operator-${{ steps.chart_version.outputs.version }}.tgz oci://ghcr.io/${{ github.repository_owner }}/charts
helm push boot-operator-${{ steps.chart_version.outputs.version }}-crds.tgz oci://ghcr.io/${{ github.repository_owner }}/charts