forked from itlabsio/k8s-itlabs-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
184 lines (169 loc) · 5.01 KB
/
ci.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
name: CI
on:
push:
branches:
- '**'
tags:
- 'v*.*.*'
pull_request:
branches:
- '**'
jobs:
lint:
name: Linter
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Poetry
run: pipx install poetry
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8.15
cache: poetry
- run: poetry install
- run: poetry run pylint ./k8s-itlabs-operator
unit-tests:
name: Run unit-tests
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Poetry
run: pipx install poetry
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8.15
cache: poetry
- run: poetry install
- run: poetry run pytest -m unit ./k8s-itlabs-operator
e2e-tests:
name: Run e2e-tests
runs-on: ubuntu-latest
container:
image: docker:20.10.17
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run tests
env:
KUBECTL: v1.24.15
KIND: v0.20.0
DOCKER_IMAGE: operator:test
MANIFEST_FOLDER: ./manifests
run: |
apk add --no-cache procps
chmod +x e2e_tests/e2e-tests.sh
./e2e_tests/e2e-tests.sh
push-to-registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
needs: [lint, unit-tests, e2e-tests]
steps:
- name: Checkout the repo
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: itlabsio/k8s-itlabs-operator
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
file: ./docker/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
create-release:
name: Create release
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
needs: [lint, unit-tests, e2e-tests]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Build changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
configurationJson: |
{
"template": "#{{CHANGELOG}}\n\n<details>\n<summary>Uncategorized</summary>\n\n#{{UNCATEGORIZED}}\n</details>",
"categories": [
{
"title": "## 🚀 Features",
"labels": ["feature"]
},
{
"title": "## 🐛 Fixes",
"labels": ["fix"]
},
{
"title": "## 🔧 Refactoring",
"labels": ["refactor"]
},
{
"title": "## 🧪 Tests",
"labels": ["test"]
},
{
"title": "## ❗ Breaking changes",
"labels": ["breaking"]
},
{
"title": "## 💬 Other",
"labels": ["other"]
}
]
}
- name: Prepare manifest
env:
DOCKER_IMAGE: itlabsio/k8s-itlabs-operator:${{ github.ref_name }}
MANIFEST_FOLDER: ./manifests/
run: |
chmod +x scripts/update-manifests.sh
./scripts/update-manifests.sh
- name: Create manifests pack
run: |
zip -r manifests.zip manifests
- name: Upload manifests
uses: actions/upload-artifact@v3
with:
name: manifests
path: manifests
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
body: ${{ steps.build_changelog.outputs.changelog }}
- name: Upload release asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./manifests.zip
asset_name: manifests.zip
asset_content_type: application/zip