1+ name : Publish OpenG2P Helm charts
2+
3+ on :
4+ push :
5+ tags :
6+ - ' **'
7+ branches-ignore :
8+ - develop
9+ - main
10+
11+
12+ jobs :
13+ generate-charts :
14+ runs-on : ubuntu-latest
15+ env :
16+ SKIP : ' FALSE'
17+ RANCHER_CHART_FILTER : " openg2p.org/add-to-rancher"
18+ defaults :
19+ run :
20+ shell : bash
21+ steps :
22+ - name : Checkout Repository
23+ uses : actions/checkout@v3
24+
25+ - id : files
26+ uses : jitterbit/get-changed-files@v1
27+
28+ - name : save helm/charts to tmp.txt file
29+ run : |
30+ touch charts-list.txt
31+ for changed_file in ${{ steps.files.outputs.all }}; do
32+ if [[ ${changed_file} =~ ^charts ]]; then
33+ chart_name=$(echo "${changed_file}" | awk -F/ '/^[charts]/{print $2}')
34+ echo $chart_name >> charts-list.txt;
35+ echo "Saved $chart_name chart to charts-list.txt"
36+ fi
37+ done
38+ cat charts-list.txt | sort | uniq > charts-list-unique.txt
39+ mv charts-list-unique.txt charts-list.txt
40+ echo "List of charts to be published";
41+ cat charts-list.txt
42+
43+ - name : Generate tar files
44+ run : |
45+ if [[ ! -s charts-list.txt ]]; then
46+ echo "::warning::No Charts to publish";
47+ echo "SKIP=TRUE" >> $GITHUB_ENV
48+ else
49+ RANCHER_CHARTS=()
50+ while IFS= read -r chartpath; do
51+ echo "chartpath: $chartpath"
52+ chartname=$(basename "$chartpath")
53+ echo "Chartname: $chartname"
54+ helm dep up charts/$chartpath
55+ helm package charts/$chartpath
56+ is_rancher_chart=$(grep "$RANCHER_CHART_FILTER" charts/${chartpath%*/}/Chart.yaml || true)
57+ if [ -n "$is_rancher_chart" ]; then
58+ RANCHER_CHARTS+=("$chartname")
59+ fi
60+ done < charts-list.txt
61+ echo "RANCHER_CHARTS=${RANCHER_CHARTS[@]}" >> $GITHUB_ENV
62+ rm charts-list.txt
63+ fi
64+
65+ shopt -s nocasematch
66+ if [[ '${{ github.repository_owner }}' != 'OpenG2P' ]]; then
67+ echo "SKIP=TRUE" >> $GITHUB_ENV
68+ fi
69+ - name : Upload tar as Artifact
70+ uses : actions/upload-artifact@v4
71+ with :
72+ name : charts
73+ path : ./*.tgz
74+ if : env.SKIP != 'TRUE'
75+
76+ - name : Checkout branch for publishing
77+ uses : actions/checkout@v3
78+ with :
79+ repository : ' openg2p/openg2p-helm'
80+ ref : gh-pages
81+ token : ${{ secrets.OPENG2P_BOT_GITHUB_PAT }}
82+ if : env.SKIP != 'TRUE'
83+
84+ - name : Download tar from Artifacts
85+ uses : actions/download-artifact@v4
86+ with :
87+ name : charts
88+ path : ./
89+ if : env.SKIP != 'TRUE'
90+
91+ - name : Update index.yaml
92+ run : |
93+ helm repo index .
94+ for chartname in $RANCHER_CHARTS; do
95+ cp ${chartname}*.tgz rancher/
96+ done
97+ helm repo index --url ../ --merge rancher/index.yaml rancher
98+ for chartname in $RANCHER_CHARTS; do
99+ rm rancher/${chartname}*.tgz || true
100+ done
101+ if : env.SKIP != 'TRUE'
102+
103+ - name : Commit Changes to repository
104+ uses : EndBug/add-and-commit@v7
105+ with :
106+ branch : gh-pages
107+ author_name : openg2pbot
108+ author_email : bot@openg2p.org
109+ default_author : user_info
110+ message : ' added openg2p pbms helm charts for publish openg2p/openg2p-pbms-deployment@${{ github.sha }}'
111+ add : ' ./*.tgz ./index.yaml rancher/index.yaml'
112+ if : env.SKIP != 'TRUE'
0 commit comments