-
Notifications
You must be signed in to change notification settings - Fork 149
141 lines (120 loc) · 6.55 KB
/
run-helm.yml
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Helm
on:
push:
branches: [ main ]
paths:
- .github/workflows/run-helm.yml
- deployment/**
- version.txt
pull_request:
branches: [ main ]
paths:
- .github/workflows/run-helm.yml
- deployment/**
- version.txt
release:
types:
- published
env:
helm_version: "3.2.1"
jobs:
lint-with-current-helm:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout the head commit of the branch
uses: actions/checkout@v3
with:
persist-credentials: false
- uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Lint helm chart
run: |
helm lint deployment/helm --values test/helm-lint-values.yaml && echo "lint finished successfully" || echo ::warning::"lint found issues"
helm lint deployment/helm --values test/helm-lint-values-jobs.yaml && echo "lint with Job brokers finished successfully" || echo ::warning::"lint with Job brokers found issues"
helm:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout the head commit of the branch
uses: actions/checkout@v3
with:
persist-credentials: false
- uses: azure/setup-helm@v3
with:
version: "v3.4.0"
# We should generate two sets of akri charts.
# One for our releases (akri) and one for our merged PRs (akri-dev). 'akri' should only be created for
# our releases and should default to not use dev containers. 'akri-dev'
# should build for any merged PR and should default to use our dev containers.
- name: When event_name == release, create akri chart
if: (github.event_name == 'release')
run: |
sed -i s/"name: akri"/"name: akri"/g ./deployment/helm/Chart.yaml
sed -i s/"description: A Helm chart for Akri"/"description: A Helm chart for Akri releases"/g ./deployment/helm/Chart.yaml
sed -i s/"useDevelopmentContainers: true"/"useDevelopmentContainers: false"/g ./deployment/helm/values.yaml
- name: When event_name != release, create akri-dev chart
if: (github.event_name != 'release')
run: |
sed -i s/"name: akri"/"name: akri-dev"/g ./deployment/helm/Chart.yaml
sed -i s/"description: A Helm chart for Akri"/"description: A Helm chart for Akri development"/g ./deployment/helm/Chart.yaml
sed -i s/"useDevelopmentContainers: true"/"useDevelopmentContainers: true"/g ./deployment/helm/values.yaml
- name: Lint helm chart
run: helm lint deployment/helm --values test/helm-lint-values.yaml && echo "lint finished successfully" || echo ::warning::"lint found issues"
- name: Ensure chart builds when setting expected values
run: helm template deployment/helm --values test/helm-lint-values.yaml
- name: Cache version.txt
run: |
mkdir -p /tmp/helm/repo
cp version.txt /tmp/helm/repo/version.txt
- name: Create new helm package
run: helm package --dependency-update --destination /tmp/helm/repo deployment/helm
- name: Inspect helm package
run: helm inspect all $(find /tmp/helm/repo -name "akri-*.tgz")
- name: Upload new helm package as artifact
if: (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref != 'refs/heads/main')
uses: actions/upload-artifact@v3
with:
name: charts
path: /tmp/helm/repo
- name: Checkout gh-pages
if: (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref != 'refs/heads/main')
uses: actions/checkout@v3
with:
ref: gh-pages
persist-credentials: false
- name: Get new chart from artifact path
if: (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref != 'refs/heads/main')
shell: bash
run: |
mv /tmp/helm/repo/* .
find .
- name: Create new merged helm chart index
if: (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref != 'refs/heads/main')
run: helm repo index --url https://project-akri.github.io/akri --merge index.yaml .
- name: Upload new merged helm chart index as artifact
if: (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref != 'refs/heads/main')
uses: actions/upload-artifact@v3
with:
name: index
path: index.yaml
- name: Create push with new akri chart for gh-pages
if: (github.event_name == 'release')
shell: bash
run: git add akri-$(cat version.txt).tgz
- name: Create push with new akri-dev chart for gh-pages
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref != 'refs/heads/main')
shell: bash
run: git add akri-dev-$(cat version.txt).tgz
- name: Push gh-pages
if: (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref != 'refs/heads/main')
shell: bash
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add index.yaml
git status
echo "Update Helm Repo for version $(cat version.txt)" | git commit --file -
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git gh-pages