Skip to content

Commit fac6db7

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

File tree

1 file changed

+65
-15
lines changed

1 file changed

+65
-15
lines changed

.github/workflows/bbm_build_container.yml

Lines changed: 65 additions & 15 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,31 +26,47 @@ 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: >
5472
github.ref == 'refs/heads/dev' &&
@@ -65,39 +83,71 @@ jobs:
6583
else
6684
echo "Not pushing images to registry"
6785
fi
86+
6887
- name: Login to ghcr.io
6988
if: ${{ env.DEPLOY_IMAGES == 'true' }}
7089
uses: docker/login-action@v2
7190
with:
7291
registry: ghcr.io
7392
username: ${{ github.actor }}
7493
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' }}
7797
run: |
78-
msg="Push docker images to ghcr.io"
79-
line="${msg//?/=}"
80-
printf "\n${line}\n${msg}\n${line}\n"
8198
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+
82103
skopeo copy --all --src-tls-verify=0 \
83104
docker://localhost:5000/${{ env.REPO }}:${image} \
84105
docker://ghcr.io/mariadb/buildbot:dev_${image}
85106
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+
86121
- name: Login to quay.io
87122
if: ${{ env.DEPLOY_IMAGES == 'true' }}
88123
uses: docker/login-action@v2
89124
with:
90125
registry: quay.io
91126
username: ${{ secrets.QUAY_USER }}
92127
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' }}
95131
run: |
96-
msg="Push docker images to quay.io"
97-
line="${msg//?/=}"
98-
printf "\n${line}\n${msg}\n${line}\n"
99132
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+
100137
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}
103153
done

0 commit comments

Comments
 (0)