generated from cloudoperators/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (80 loc) · 2.91 KB
/
helm-release.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
name: Package Helm Chart and publish to GitHub Packages
on:
workflow_dispatch: {}
push:
branches:
- main
paths:
- .github/workflows/helm-release.yaml
- charts/heureka
permissions:
contents: write
packages: write
env:
REGISTRY: ghcr.io
ACTIONS_RUNNER_DEBUG: false
jobs:
helm-release:
runs-on: [ default ]
strategy:
fail-fast: false
matrix:
include:
- chartDir: charts/heureka
chartName: heureka
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Set up Helm
uses: azure/[email protected]
- uses: actions/setup-python@v5
with:
python-version: 3.9
check-latest: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
${{ matrix.chartDir }}/**
- name: Check if Helm chart with same version already exists
id: check-chart
if: steps.changed-files.outputs.all_changed_files != ''
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
# List all changed
echo "All changed files: $ALL_CHANGED_FILES"
chartName=$(yq .name "${{ matrix.chartDir }}/Chart.yaml")
chartVersion=$(yq .version "${{ matrix.chartDir }}/Chart.yaml")
echo "chart_version=${chartVersion}" >> "$GITHUB_OUTPUT"
if $(helm pull "oci://${{ env.REGISTRY }}/${{ github.repository }}/charts/${{ matrix.chartName }}" --version $chartVersion); then
echo "bump=true" >> "$GITHUB_OUTPUT"
fi
- name: Chart needs version bump
if: steps.check-chart.outputs.bump == 'true'
env:
CHART_VERSION: ${{ steps.check-chart.outputs.chart_version }}
run: |
echo "Chart ${{ matrix.chartDir }}:${{ env.CHART_VERSION }} already exists in OCI registry. Skipping upload. Please increment the chart version."
exit 1
- name: Push Charts to GHCR
if: steps.changed-files.outputs.all_changed_files != '' && steps.check-chart.outputs.bump != 'true'
run: |
helm package ${{ matrix.chartDir }} -d ${{ matrix.chartDir }}
PKG_NAME=`ls ${{ matrix.chartDir }}/*.tgz`
helm push ${PKG_NAME} oci://${{ env.REGISTRY }}/${{ github.repository }}/charts/