-
Notifications
You must be signed in to change notification settings - Fork 5
118 lines (99 loc) · 3.37 KB
/
publish.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Release
on:
push:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
env:
HELM_VERSION: v3.0.2
CONFTEST_VERSION: "0.15.0"
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Conftest Install
run: |
curl -sSL https://github.com/instrumenta/conftest/releases/download/v${CONFTEST_VERSION}/conftest_${CONFTEST_VERSION}_Linux_x86_64.tar.gz \
| tar vxz \
&& sudo mv -v conftest /usr/local/bin/conftest
- name: Install YQ
run: |
curl -sSL https://github.com/mikefarah/yq/releases/download/v4.20.1/yq_linux_amd64 -o yq && chmod +x yq && sudo mv yq /usr/local/bin
- name: Helm Install
run: |
curl -sSL https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz \
| tar vxz \
&& sudo mv -v linux-amd64/helm /usr/local/bin/helm \
&& rm -vrf linux-amd64
- name: Helm Lint
run: ./helm-test.sh
publish:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/master'
env:
HELM_VERSION: v3.0.2
HELM_TMP_DIR: /tmp/helm-tmp-package
HELM_RELEASE_DIR: release
HELM_RELEASE_BRANCH: gh-pages
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Helm Install
run: |
curl -sSL https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz \
| tar vxz \
&& sudo mv -v linux-amd64/helm /usr/local/bin/helm \
&& rm -vrf linux-amd64
# Package
- name: Helm Package
run: |
mkdir -p ${HELM_TMP_DIR}
./helm-package.sh ${HELM_TMP_DIR}
ls -la ${HELM_TMP_DIR}
# Publish
- uses: actions/checkout@v3
with:
ref: gh-pages
path: ./gh-pages
token: ${{ secrets.GITHUB_TOKEN }}
- name: Debug
run: |
ls -la .
ls -la ${HELM_RELEASE_BRANCH}
ls -la ${HELM_RELEASE_BRANCH}/${HELM_RELEASE_DIR}
ls -la ${HELM_TMP_DIR}
- name: Helm Publish
run: |
cd ${HELM_RELEASE_BRANCH}
for chart in ${HELM_TMP_DIR}/*; do
chart=$(basename $chart)
echo $chart
if [ ! -f "${HELM_RELEASE_DIR}/${chart}" ]; then
mv -vn "${HELM_TMP_DIR}/${chart}" "${HELM_RELEASE_DIR}/${chart}"
else
echo "Chart $chart is already released!"
fi
done
# Generate new index.yaml
helm repo index ${HELM_RELEASE_DIR} --url ${HELM_RELEASE_DIR}
# Move generated index.yaml to root dir
mv ${HELM_RELEASE_DIR}/index.yaml .
- name: Git Push
run: |
cd ${HELM_RELEASE_BRANCH}
git add -v ${HELM_RELEASE_DIR}
git status
if ! $(git diff-index --quiet HEAD -- ${HELM_RELEASE_DIR}/*); then
git add -v index.yaml
git status
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "${GITHUB_ACTOR}"
git commit -am "AUTO-RELEASE: publish Helm Charts from master@${GITHUB_SHA:0:7}"
git push "https://${{ secrets.GITHUB_PAT }}@github.com/${GITHUB_REPOSITORY}.git"
else
echo "No new packages to push"
fi