forked from kadalu/kadalu
-
Notifications
You must be signed in to change notification settings - Fork 1
176 lines (168 loc) · 5.61 KB
/
on-pr-merge.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
name: "On Merge"
# This gets built when a PR gets merged
on:
push:
paths-ignore:
- 'doc/**'
- '**.md'
- 'extras/**'
- 'helm/**'
branches:
- devel
# Add tags later (for pushing release)
jobs:
devel-tag-push:
runs-on: ubuntu-latest
steps:
- name: Check out Code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Python (for cli-build)
uses: actions/setup-python@v1
with:
python-version: '3.10'
- uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/ci_merge-requirements.txt') }}
- name: Get the CLI build (kubectl-kadalu)
run: |
python -m pip install --upgrade --upgrade-strategy eager -r requirements/ci_merge-requirements.txt -e ./requirements
KADALU_VERSION=devel make cli-build
- name: Check to build and push base image or not
id: build_base
run: |
# same conditions as mentioned in submit workflow
FILES=$(git show --pretty="" --name-only)
build_base='no'
if grep -e 'CHANGELOG.md' <<< "$b" && [ $(wc -w <<< "$b") == 1 ]; then
build_base='yes'
elif grep -e 'extras/Dockerfile.builder' <<< "$FILES"; then
build_base='yes'
fi
echo ::set-output name=out::$build_base
- name: Builder Image
if: "contains(steps.build_base.outputs.build_base, 'yes')"
uses: docker/build-push-action@v2
timeout-minutes: 120
with:
context: .
file: extras/Dockerfile.builder
platforms: linux/amd64
push: true
load: true
tags: |
docker.io/kadalu/builder:latest
build-args: |
version==${{ github.sha }}
builddate=`date +%Y-%m-%d-%H:%M`
secrets: |
KADALU_VERSION=${{ github.sha }}
- name: Build CSI Image and push
uses: docker/build-push-action@v2
timeout-minutes: 120
with:
context: .
file: csi/Dockerfile
platforms: linux/amd64
target: prod
push: true
tags: |
docker.io/kadalu/kadalu-csi:${{ github.sha }}
docker.io/kadalu/kadalu-csi:devel
build-args: |
version==${{ github.sha }}
builddate=`date +%Y-%m-%d-%H:%M`
secrets: |
KADALU_VERSION=${{ github.sha }}
- name: Build Operator Image and push
uses: docker/build-push-action@v2
timeout-minutes: 20
with:
context: .
file: kadalu_operator/Dockerfile
platforms: linux/amd64
target: prod
push: true
tags: |
docker.io/kadalu/kadalu-operator:${{ github.sha }}
docker.io/kadalu/kadalu-operator:devel
build-args: |
version==${{ github.sha }}
builddate=`date +%Y-%m-%d-%H:%M`
secrets: |
KADALU_VERSION=${{ github.sha }}
- name: Build Storage Server Image and push
uses: docker/build-push-action@v2
timeout-minutes: 20
with:
context: .
file: server/Dockerfile
platforms: linux/amd64
target: prod
push: true
tags: |
docker.io/kadalu/kadalu-server:${{ github.sha }}
docker.io/kadalu/kadalu-server:devel
build-args: |
version==${{ github.sha }}
builddate=`date +%Y-%m-%d-%H:%M`
secrets: |
KADALU_VERSION=${{ github.sha }}
# What follows are basically building and pushing of tests images conditionally
- name: Check for Dockerfile changes in tests folder
id: build_test
run: |
build_test='no'
# Get files part of the merge
FILES=$(git show --pretty="" --name-only)
if grep -e '^tests.*Dockerfile$' <<< "$FILES"; then
build_test='yes'
fi
echo ::set-output name=build_test::$build_test
- name: Build test-io image used in CI
if: "contains(steps.build_test.outputs.build_test, 'yes')"
uses: docker/build-push-action@v2
timeout-minutes: 10
with:
context: .
file: tests/test-io/Dockerfile
platforms: linux/amd64
target: prod
push: true
tags: |
docker.io/kadalu/test-io:${{ github.sha }}
docker.io/kadalu/test-io:devel
build-args: |
version==${{ github.sha }}
builddate=`date +%Y-%m-%d-%H:%M`
secrets: |
KADALU_VERSION=${{ github.sha }}
- name: Build test-csi image used in CI
if: "contains(steps.build_test.outputs.build_test, 'yes')"
uses: docker/build-push-action@v2
timeout-minutes: 10
with:
context: .
file: tests/test-csi/Dockerfile
platforms: linux/amd64
target: prod
push: true
tags: |
docker.io/kadalu/test-csi:${{ github.sha }}
docker.io/kadalu/test-csi:devel
build-args: |
version==${{ github.sha }}
builddate=`date +%Y-%m-%d-%H:%M`
secrets: |
KADALU_VERSION=${{ github.sha }}