-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (67 loc) · 2.39 KB
/
update-index.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
name: Deploy New Helm Chart to gh-pages
on:
push:
branches:
- main
paths:
- "**/Chart.yaml"
jobs:
deploy-chart:
runs-on: ubuntu-latest
steps:
- name: Checkout Main Branch
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Helm
run: |
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Identify Newly Added Charts
id: find-new-charts
run: |
NEW_CHARTS=$(git diff --name-status HEAD^ HEAD | grep "^A" | grep "Chart.yaml" | awk '{print $2}' | xargs -n1 dirname)
if [[ -z "$NEW_CHARTS" ]]; then
echo "No new charts detected."
exit 0
fi
echo "::set-output name=new_charts::$NEW_CHARTS"
shell: bash
- name: Debug Find New Charts
run: echo "Found new charts: ${{ steps.find-new-charts.outputs.new_charts }}"
- name: Package New Helm Charts
if: ${{ steps.find-new-charts.outputs.new_charts != '' }}
run: |
echo "Packaging charts: ${{ steps.find-new-charts.outputs.new_charts }}"
mkdir -p packaged-charts
for chart in ${{ steps.find-new-charts.outputs.new_charts }}; do
echo "Packaging chart: $chart"
helm package $chart --destination packaged-charts
done
- name: Checkout gh-pages Branch
if: ${{ steps.find-new-charts.outputs.new_charts != '' }}
uses: actions/checkout@v3
with:
ref: gh-pages
- name: Copy Packaged Charts
if: ${{ steps.find-new-charts.outputs.new_charts != '' }}
run: |
mkdir -p charts
if ls ../packaged-charts/*.tgz 1> /dev/null 2>&1; then
mv ../packaged-charts/*.tgz charts/
else
echo "No packaged charts found to move."
fi
- name: Update Helm Repo Index
if: ${{ steps.find-new-charts.outputs.new_charts != '' }}
run: |
helm repo index charts --url https://nodeify-eth.github.io/helm-charts/charts/
- name: Commit and Push Changes
if: ${{ steps.find-new-charts.outputs.new_charts != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add charts
git commit -m "Add new Helm chart(s) and update index"
git push