16
16
build :
17
17
runs-on : ubuntu-22.04
18
18
name : build
19
+ env :
20
+ MAIN_BRANCH : false
19
21
services :
20
22
registry :
21
23
image : registry:2
@@ -24,31 +26,47 @@ jobs:
24
26
25
27
steps :
26
28
- uses : actions/checkout@v4
27
- - name : Check Dockerfile with hadolint
28
- run : |
29
- docker run -i -v $(pwd):/mnt -w /mnt ghcr.io/hadolint/hadolint:latest hadolint /mnt/Dockerfile
29
+
30
+ - name : Enable Production release - no rebuild
31
+ run : echo "MAIN_BRANCH=true" >> $GITHUB_ENV
32
+ if : github.ref == 'refs/heads/main'
33
+
30
34
- name : Set up env vars
31
35
run : |
32
36
echo "REPO=bb-master" >>$GITHUB_ENV
37
+
38
+ - name : Check Dockerfile with hadolint
39
+ if : ${{ env.MAIN_BRANCH == 'false' }}
40
+ run : |
41
+ docker run -i -v $(pwd):/mnt -w /mnt ghcr.io/hadolint/hadolint:latest hadolint /mnt/Dockerfile
42
+
33
43
- name : Build master image
44
+ if : ${{ env.MAIN_BRANCH == 'false' }}
34
45
run : |
35
46
podman build . --tag ${{ env.REPO }}:master
47
+
36
48
- name : Build master-web image
49
+ if : ${{ env.MAIN_BRANCH == 'false' }}
37
50
run : |
38
51
podman build . --tag ${{ env.REPO }}:master-web \
39
52
--build-arg master_type=master-web
53
+
40
54
- name : Push images to local registry
55
+ if : ${{ env.MAIN_BRANCH == 'false' }}
41
56
run : |
42
57
for img in master master-web; do
43
58
podman push --tls-verify=0 \
44
59
${{ env.REPO }}:$img \
45
60
docker://localhost:5000/${{ env.REPO }}:$img
46
61
done
62
+
47
63
- name : Check images
64
+ if : ${{ env.MAIN_BRANCH == 'false' }}
48
65
run : |
49
66
docker run -i localhost:5000/${{ env.REPO }}:master buildbot --version
50
67
#//TEMP there is probably a better way for master-web here
51
68
docker run -i localhost:5000/${{ env.REPO }}:master-web buildbot --version
69
+
52
70
- name : Check for registry credentials
53
71
if : >
54
72
github.ref == 'refs/heads/dev' &&
@@ -65,39 +83,71 @@ jobs:
65
83
else
66
84
echo "Not pushing images to registry"
67
85
fi
86
+
68
87
- name : Login to ghcr.io
69
88
if : ${{ env.DEPLOY_IMAGES == 'true' }}
70
89
uses : docker/login-action@v2
71
90
with :
72
91
registry : ghcr.io
73
92
username : ${{ github.actor }}
74
93
password : ${{ secrets.GITHUB_TOKEN }}
75
- - name : Push images to ghcr.io
76
- if : ${{ env.DEPLOY_IMAGES == 'true' }}
94
+
95
+ - name : Push DEV images to ghcr.io
96
+ if : ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH == 'false' }}
77
97
run : |
78
- msg="Push docker images to ghcr.io"
79
- line="${msg//?/=}"
80
- printf "\n${line}\n${msg}\n${line}\n"
81
98
for image in master master-web; do
99
+ msg="Push docker image to quay.io (${image})"
100
+ line="${msg//?/=}"
101
+ printf "\n${line}\n${msg}\n${line}\n"
102
+
82
103
skopeo copy --all --src-tls-verify=0 \
83
104
docker://localhost:5000/${{ env.REPO }}:${image} \
84
105
docker://ghcr.io/mariadb/buildbot:dev_${image}
85
106
done
107
+
108
+ - name : ghcr.io - backup Production tag
109
+ if : ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH =='true' }}
110
+ run :
111
+ for image in master master-web; do
112
+ msg="Create backup for ${image} on ghcr.io"
113
+ line="${msg//?/=}"
114
+ printf "\n${line}\n${msg}\n${line}\n"
115
+
116
+ skopeo copy --all --src-tls-verify=0 \
117
+ docker://ghcr.io/mariadb/buildbot:${image} \
118
+ docker://ghcr.io/mariadb/buildbot:previous_${image}
119
+ done
120
+
86
121
- name : Login to quay.io
87
122
if : ${{ env.DEPLOY_IMAGES == 'true' }}
88
123
uses : docker/login-action@v2
89
124
with :
90
125
registry : quay.io
91
126
username : ${{ secrets.QUAY_USER }}
92
127
password : ${{ secrets.QUAY_TOKEN }}
93
- - name : Push images to quay.io
94
- if : ${{ env.DEPLOY_IMAGES == 'true' }}
128
+
129
+ - name : Push DEV images to quay.io
130
+ if : ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH == 'false' }}
95
131
run : |
96
- msg="Push docker images to quay.io"
97
- line="${msg//?/=}"
98
- printf "\n${line}\n${msg}\n${line}\n"
99
132
for image in master master-web; do
133
+ msg="Push docker image to quay.io (${image})"
134
+ line="${msg//?/=}"
135
+ printf "\n${line}\n${msg}\n${line}\n"
136
+
100
137
skopeo copy --all --src-tls-verify=0 \
101
- docker://localhost:5000/${{ env.REPO }}:${image} \
102
- docker://quay.io/mariadb-foundation/${{ env.REPO }}:dev_${image}
138
+ docker://localhost:5000/${{ env.REPO }}:${image} \
139
+ docker://quay.io/mariadb-foundation/${{ env.REPO }}:dev_${image}
140
+ done
141
+
142
+ - name : quay.io - backup Production tagquay
143
+ if : ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH =='true' }}
144
+ run :
145
+ for image in master master-web; do
146
+ msg="Create backup for ${image} on quay.io"
147
+ line="${msg//?/=}"
148
+ printf "\n${line}\n${msg}\n${line}\n"
149
+
150
+ skopeo copy --all --src-tls-verify=0 \
151
+ docker://quay.io/mariadb-foundation/${{ env.REPO }}:${image} \
152
+ docker://quay.io/mariadb-foundation/${{ env.REPO }}:previous_${image}
103
153
done
0 commit comments