-
Notifications
You must be signed in to change notification settings - Fork 25
152 lines (131 loc) · 4.94 KB
/
bbm_build_container.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
---
name: bbm-build-container
on:
workflow_dispatch:
push:
paths:
- "Dockerfile"
- .github/workflows/bbm_build_container.yml
pull_request:
paths:
- "Dockerfile"
- .github/workflows/bbm_build_container.yml
jobs:
build:
runs-on: ubuntu-22.04
name: build
env:
MAIN_BRANCH: false
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- uses: actions/checkout@v4
- name: Enable Production release - no rebuild
run: echo "MAIN_BRANCH=true" >> $GITHUB_ENV
if: github.ref == 'refs/heads/main'
- name: Set up env vars
run: |
echo "REPO=bb-master" >>$GITHUB_ENV
- name: Check Dockerfile with hadolint
if: ${{ env.MAIN_BRANCH == 'false' }}
run: |
docker run -i -v $(pwd):/mnt -w /mnt ghcr.io/hadolint/hadolint:latest hadolint /mnt/Dockerfile
- name: Build master image
if: ${{ env.MAIN_BRANCH == 'false' }}
run: |
podman build . --tag ${{ env.REPO }}:master
- name: Build master-web image
if: ${{ env.MAIN_BRANCH == 'false' }}
run: |
podman build . --tag ${{ env.REPO }}:master-web \
--build-arg master_type=master-web
- name: Push images to local registry
if: ${{ env.MAIN_BRANCH == 'false' }}
run: |
for img in master master-web; do
podman push --tls-verify=0 \
${{ env.REPO }}:$img \
docker://localhost:5000/${{ env.REPO }}:$img
done
- name: Check images
if: ${{ env.MAIN_BRANCH == 'false' }}
run: |
docker run -i localhost:5000/${{ env.REPO }}:master buildbot --version
#//TEMP there is probably a better way for master-web here
docker run -i localhost:5000/${{ env.REPO }}:master-web buildbot --version
- name: Check for registry credentials
if: >
github.repository == 'MariaDB/buildbot'
run: |
missing=()
[[ -n "${{ secrets.QUAY_USER }}" ]] || missing+=(QUAY_USER)
[[ -n "${{ secrets.QUAY_TOKEN }}" ]] || missing+=(QUAY_TOKEN)
for i in "${missing[@]}"; do
echo "Missing github secret: $i"
done
if (( ${#missing[@]} == 0 )); then
echo "DEPLOY_IMAGES=true" >> $GITHUB_ENV
else
echo "Not pushing images to registry"
fi
- name: Login to ghcr.io
if: ${{ env.DEPLOY_IMAGES == 'true' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push DEV images to ghcr.io
if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH == 'false' }}
run: |
for image in master master-web; do
msg="Push docker image to ghcr.io (${image})"
line="${msg//?/=}"
printf "\n${line}\n${msg}\n${line}\n"
skopeo copy --all --src-tls-verify=0 \
docker://localhost:5000/${{ env.REPO }}:${image} \
docker://ghcr.io/mariadb/buildbot:dev_${image}
done
- name: ghcr.io - backup Production tag
if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH =='true' }}
run:
for image in master master-web; do
msg="Create backup for ${image} on ghcr.io"
line="${msg//?/=}"
printf "\n${line}\n${msg}\n${line}\n"
skopeo copy --all --src-tls-verify=0 \
docker://ghcr.io/mariadb/buildbot:${image} \
docker://ghcr.io/mariadb/buildbot:previous_${image}
done
- name: Login to quay.io
if: ${{ env.DEPLOY_IMAGES == 'true' }}
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Push DEV images to quay.io
if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH == 'false' }}
run: |
for image in master master-web; do
msg="Push docker image to quay.io (${image})"
line="${msg//?/=}"
printf "\n${line}\n${msg}\n${line}\n"
skopeo copy --all --src-tls-verify=0 \
docker://localhost:5000/${{ env.REPO }}:${image} \
docker://quay.io/mariadb-foundation/${{ env.REPO }}:dev_${image}
done
- name: quay.io - backup Production tag
if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH =='true' }}
run:
for image in master master-web; do
msg="Create backup for ${image} on quay.io"
line="${msg//?/=}"
printf "\n${line}\n${msg}\n${line}\n"
skopeo copy --all --src-tls-verify=0 \
docker://quay.io/mariadb-foundation/${{ env.REPO }}:${image} \
docker://quay.io/mariadb-foundation/${{ env.REPO }}:previous_${image}
done