-
Notifications
You must be signed in to change notification settings - Fork 6
198 lines (176 loc) · 7.41 KB
/
docker-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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Docker Image CI
on:
push:
workflow_dispatch:
inputs:
msg:
description: "Msg instead of commit log"
required: true
default: 'false'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Change Chart Version
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
run: |
VERSION=1.0.0 envsubst < chart/Chart.yaml | tee tmp-file && mv tmp-file chart/Chart.yaml
cat chart/Chart.yaml
- name: Set up Helm
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
uses: azure/setup-helm@v3.4
- name: Run chart-testing (lint)
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
run: helm lint chart/
- name: Create kind cluster
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
uses: helm/kind-action@v1.2.0
- name: Install Crds
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
run: kubectl apply -f chart/crds/ ; sleep 2
- name: Run chart-testing (install)
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
run: helm install cnvrg ./chart --dry-run --namespace=cnvrg --debug
- name: Bump version and push tag
uses: AccessibleAI/github-tag-action@1.0.0
id: tag_bump
env:
MSG: ${{ github.event.inputs.msg }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PRERELEASE_AUTOMATIC_BUMP: true
WITH_V: false
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
architecture: x64
if: ${{ steps.tag_bump.outputs.bumped == 'true' && steps.tag_bump.outputs.prerelease == 'false' }}
- name: Extract repo/branch name
shell: bash
if: ${{ steps.tag_bump.outputs.bumped == 'true' }}
run: |
echo "::set-output name=docker_repo::cnvrg-operator"
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/*/})"
echo "##[set-output name=head;]$(git rev-parse --short HEAD)"
echo "##[set-output name=repo_url;]$(echo $GITHUB_SERVER_URL/$GITHUB_REPOSITORY)"
id: extract_info
- name: Login to Docker Hub
uses: docker/login-action@v1
if: ${{ steps.tag_bump.outputs.bumped == 'true' }}
with:
username: ${{ secrets.DOCKER_USER}}
password: ${{ secrets.DOCKER_PASSWORD}}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
if: ${{ steps.tag_bump.outputs.bumped == 'true' }}
- name: Build and push main latest
id: docker_build_main
uses: docker/build-push-action@v2
if: ${{ steps.tag_bump.outputs.bumped == 'true' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }}
with:
context: ./
file: ./Dockerfile
push: true
tags: cnvrg/${{ steps.extract_info.outputs.docker_repo }}:latest
build-args: |
BUILD_SHA=${{ steps.extract_info.outputs.head }}
BUILD_VERSION=latest
- name: Build and push tagged image
id: docker_build_tag
uses: docker/build-push-action@v2
if: ${{ steps.tag_bump.outputs.bumped == 'true' }}
with:
context: ./
file: ./Dockerfile
push: true
tags: cnvrg/${{ steps.extract_info.outputs.docker_repo }}:${{ steps.tag_bump.outputs.new_tag }}
build-args: |
BUILD_SHA=${{ steps.extract_info.outputs.head }}
BUILD_VERSION=${{ steps.tag_bump.outputs.new_tag }}
- name: Generate Cnvrg Changelog
uses: AccessibleAI/github-changelog-action@1.0.0
id: cnvrg_changelog
with:
from_version: ${{ steps.tag_bump.outputs.tag }}
to_version: ${{ steps.tag_bump.outputs.new_tag }}
jira_token: ${{ secrets.JIRA_TOKEN }}
slack_webhook_url: false
if: ${{ steps.tag_bump.outputs.bumped == 'true' && steps.tag_bump.outputs.prerelease == 'false' }}
- name: Generate Non Cnvrg Changelog
id: changelog
uses: metcalfc/changelog-generator@v3.0.0
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
head-ref: ${{ steps.tag_bump.outputs.tag }}
base-ref: ${{ steps.tag_bump.outputs.new_tag }}
if: ${{ steps.cnvrg_changelog.outputs.empty == 'true' && steps.tag_bump.outputs.bumped == 'true' && steps.tag_bump.outputs.prerelease == 'false' }}
- name: Generate changelog
id: changelog_final
if: ${{ steps.tag_bump.outputs.bumped == 'true' && steps.tag_bump.outputs.prerelease == 'false' }}
run: |
set -o noglob
if ${{ steps.cnvrg_changelog.outputs.empty }}; then
log=$(cat << "EOF"
${{ steps.changelog.outputs.changelog }}
EOF
)
else
log=$(cat << "EOF"
${{ steps.cnvrg_changelog.outputs.changelog }}
EOF
)
fi
log="${log//'%'/'%25'}"
log="${log//$'\n'/'%0A'}"
log="${log//$'\r'/'%0D'}"
echo "::set-output name=changelog::$log"
- name: Print the final changelog
if: ${{ steps.tag_bump.outputs.bumped == 'true' && steps.tag_bump.outputs.prerelease == 'false' }}
run: |
cat << "EOF"
${{ steps.changelog_final.outputs.changelog }}
EOF
- name: Changelog Release
uses: softprops/action-gh-release@v1
with:
body: ${{steps.changelog_final.outputs.changelog}}
tag_name: ${{ steps.tag_bump.outputs.new_tag }}
prerelease: ${{ steps.tag_bump.outputs.prerelease }}
generate_release_notes: true
if: ${{ steps.tag_bump.outputs.bumped == 'true' && steps.tag_bump.outputs.prerelease == 'false' }}
- name: Change Chart Version
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
run: |
sed -i 's#1.0.0#${{ steps.tag_bump.outputs.new_tag }}#g' chart/Chart.yaml
cat chart/Chart.yaml
- name: Package and release helm
if: ${{ steps.tag_bump.outputs.bumped == 'true' && steps.tag_bump.outputs.prerelease == 'false' }}
env:
CHARTMUSEUM_USER: ${{ secrets.CHARTMUSEUM_USER }}
CHARTMUSEUM_PASSWORD: ${{ secrets.CHARTMUSEUM_PASSWORD }}
run: |
helm plugin install https://github.com/chartmuseum/helm-push.git
helm package chart -d .
helm cm-push chart https://charts.v3.cnvrg.io -u=${CHARTMUSEUM_USER} -p=${CHARTMUSEUM_PASSWORD} --force
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
if: ${{ steps.tag_bump.outputs.bumped == 'true' && steps.tag_bump.outputs.prerelease == 'false' }}
env:
SLACK_USERNAME: Github Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_GITHUB_APP_TOKEN }}
SLACK_CHANNEL: "#release-notes-metacloud"
SLACK_ICON: https://avatars.githubusercontent.com/u/44036562?s=48&v=4
SLACK_COLOR: ${{ job.status }}
SLACK_FOOTER: ""
MSG_MINIMAL: true
SLACK_TITLE: "Repo Name"
SLACK_MESSAGE: |
<${{ steps.extract_info.outputs.repo_url }}|${{github.event.repository.name}}>
*Docker Image: cnvrg/${{ steps.extract_info.outputs.docker_repo }}:${{ steps.tag_bump.outputs.new_tag }}*
*Version: ${{ steps.tag_bump.outputs.new_tag }}*
<${{ steps.extract_info.outputs.repo_url }}/releases|Release Notes:>
${{steps.changelog_final.outputs.changelog}}