Skip to content

Commit 33447ba

Browse files
MDBF-850 - Backup PROD master tag
1 parent 0583e4f commit 33447ba

File tree

1 file changed

+65
-16
lines changed

1 file changed

+65
-16
lines changed

.github/workflows/bbm_build_container.yml

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
build:
1717
runs-on: ubuntu-22.04
1818
name: build
19+
env:
20+
MAIN_BRANCH: false
1921
services:
2022
registry:
2123
image: registry:2
@@ -24,34 +26,49 @@ jobs:
2426

2527
steps:
2628
- 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+
3034
- name: Set up env vars
3135
run: |
3236
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+
3343
- name: Build master image
44+
if: ${{ env.MAIN_BRANCH == 'false' }}
3445
run: |
3546
podman build . --tag ${{ env.REPO }}:master
47+
3648
- name: Build master-web image
49+
if: ${{ env.MAIN_BRANCH == 'false' }}
3750
run: |
3851
podman build . --tag ${{ env.REPO }}:master-web \
3952
--build-arg master_type=master-web
53+
4054
- name: Push images to local registry
55+
if: ${{ env.MAIN_BRANCH == 'false' }}
4156
run: |
4257
for img in master master-web; do
4358
podman push --tls-verify=0 \
4459
${{ env.REPO }}:$img \
4560
docker://localhost:5000/${{ env.REPO }}:$img
4661
done
62+
4763
- name: Check images
64+
if: ${{ env.MAIN_BRANCH == 'false' }}
4865
run: |
4966
docker run -i localhost:5000/${{ env.REPO }}:master buildbot --version
5067
#//TEMP there is probably a better way for master-web here
5168
docker run -i localhost:5000/${{ env.REPO }}:master-web buildbot --version
69+
5270
- name: Check for registry credentials
5371
if: >
54-
github.ref == 'refs/heads/dev' &&
5572
github.repository == 'MariaDB/buildbot'
5673
run: |
5774
missing=()
@@ -65,39 +82,71 @@ jobs:
6582
else
6683
echo "Not pushing images to registry"
6784
fi
85+
6886
- name: Login to ghcr.io
6987
if: ${{ env.DEPLOY_IMAGES == 'true' }}
7088
uses: docker/login-action@v2
7189
with:
7290
registry: ghcr.io
7391
username: ${{ github.actor }}
7492
password: ${{ secrets.GITHUB_TOKEN }}
75-
- name: Push images to ghcr.io
76-
if: ${{ env.DEPLOY_IMAGES == 'true' }}
93+
94+
- name: Push DEV images to ghcr.io
95+
if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH == 'false' }}
7796
run: |
78-
msg="Push docker images to ghcr.io"
79-
line="${msg//?/=}"
80-
printf "\n${line}\n${msg}\n${line}\n"
8197
for image in master master-web; do
98+
msg="Push docker image to ghcr.io (${image})"
99+
line="${msg//?/=}"
100+
printf "\n${line}\n${msg}\n${line}\n"
101+
82102
skopeo copy --all --src-tls-verify=0 \
83103
docker://localhost:5000/${{ env.REPO }}:${image} \
84104
docker://ghcr.io/mariadb/buildbot:dev_${image}
85105
done
106+
107+
- name: ghcr.io - backup Production tag
108+
if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH =='true' }}
109+
run:
110+
for image in master master-web; do
111+
msg="Create backup for ${image} on ghcr.io"
112+
line="${msg//?/=}"
113+
printf "\n${line}\n${msg}\n${line}\n"
114+
115+
skopeo copy --all --src-tls-verify=0 \
116+
docker://ghcr.io/mariadb/buildbot:${image} \
117+
docker://ghcr.io/mariadb/buildbot:previous_${image}
118+
done
119+
86120
- name: Login to quay.io
87121
if: ${{ env.DEPLOY_IMAGES == 'true' }}
88122
uses: docker/login-action@v2
89123
with:
90124
registry: quay.io
91125
username: ${{ secrets.QUAY_USER }}
92126
password: ${{ secrets.QUAY_TOKEN }}
93-
- name: Push images to quay.io
94-
if: ${{ env.DEPLOY_IMAGES == 'true' }}
127+
128+
- name: Push DEV images to quay.io
129+
if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH == 'false' }}
95130
run: |
96-
msg="Push docker images to quay.io"
97-
line="${msg//?/=}"
98-
printf "\n${line}\n${msg}\n${line}\n"
99131
for image in master master-web; do
132+
msg="Push docker image to quay.io (${image})"
133+
line="${msg//?/=}"
134+
printf "\n${line}\n${msg}\n${line}\n"
135+
100136
skopeo copy --all --src-tls-verify=0 \
101-
docker://localhost:5000/${{ env.REPO }}:${image} \
102-
docker://quay.io/mariadb-foundation/${{ env.REPO }}:dev_${image}
137+
docker://localhost:5000/${{ env.REPO }}:${image} \
138+
docker://quay.io/mariadb-foundation/${{ env.REPO }}:dev_${image}
139+
done
140+
141+
- name: quay.io - backup Production tag
142+
if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH =='true' }}
143+
run:
144+
for image in master master-web; do
145+
msg="Create backup for ${image} on quay.io"
146+
line="${msg//?/=}"
147+
printf "\n${line}\n${msg}\n${line}\n"
148+
149+
skopeo copy --all --src-tls-verify=0 \
150+
docker://quay.io/mariadb-foundation/${{ env.REPO }}:${image} \
151+
docker://quay.io/mariadb-foundation/${{ env.REPO }}:previous_${image}
103152
done

0 commit comments

Comments
 (0)