-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (51 loc) · 1.99 KB
/
motive-chart-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
name: CI - Helm Release
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'charts/**'
- '!charts/**/README.md'
jobs:
helm-release:
runs-on: 'ubuntu-latest'
defaults:
run:
shell: sh
steps:
- name: "Checkout main branch"
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: "Configure Git"
shell: sh
run: |
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "[email protected]"
- name: "Install Helm"
uses: azure/setup-helm@v4
with:
version: v3.7.0
- name: "Add Helm repositories"
run: |
# Install yq tool to parse Chart.yaml to identify Helm dependencies repositories
wget https://github.com/mikefarah/yq/releases/download/v4.21.1/yq_linux_386 -O /usr/bin/yq && chmod +x /usr/bin/yq
# Retrieve all helm dependencies repositories and run `helm repo add` for each of them.
# Command explanation follows:
#
# yq '.dependencies.[].repository' helm/*/Chart.yaml --> Prints repository field for all Chart dependencies.
# sed 's:/*$::' --> Trims the trailing forward slash '/' at the end of the repository URL, if any
# sort | uniq ----> Removes duplicated entries, for those cases where more than 1 dependency comes
# from the same Helm repository
yq '.dependencies.[].repository' charts/*/Chart.yaml | awk '/^http/' | sed 's:/*$::' | sort | uniq | while read helm_repo; do
# Helm repo name is generated from a random string, as it is not persisted between executions.
helm repo add $(openssl rand -hex 12) ${helm_repo}
done
- name: "Run chart-releaser"
uses: helm/[email protected]
with:
charts_dir: charts
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"