Skip to content

Commit 38e8d3b

Browse files
MDBF-1109 - Auto update the Debian Sid environment
Quick recap on how images are deployed to production: 1. On Pull Request : an image is only built 2. On Push to DEV branch: the image is built and pushed to quay / ghcr but with a `dev_` prefix tag. `buildbot.dev.mariadb.org` uses images starting with`dev_` 3. On push to MAIN branch: the `dev_` tag is moved in quay / ghcr replacing the production image that doesn't have `dev_` in its name. `buildbot.mariadb.org` looks for images not having `dev_` in their name. On schedule goal: - on schedule event (which by GitHub laws is triggered on the default branch >>dev<<). We want to build the container image, push it to dev and then deploy it to prod. Framework: The dispatcher is scheduled to run on the third of the month. Child workflows having `is_scheduled_event` input will be triggered. In the child workflow only the images with `deploy_on_schedule: true` are rebuilt. In the workflow template `bbw_build_container_template.yml`: - the job runs if the run is scheduled and the matrix item has 'deploy_on_schedule: true` or for any other event type (pull request, push) If `is_scheduled_event` is True then tags are moved to Production.
1 parent d4b5d8a commit 38e8d3b

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

.github/workflows/bbw_build_container_template.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,19 @@ on:
3939
required: false
4040
type: string
4141
default: 'false'
42+
deploy_on_schedule:
43+
required: false
44+
type: boolean
45+
default: false
46+
47+
is_scheduled_event:
48+
required: false
49+
type: boolean
50+
default: false
4251

4352
jobs:
4453
build:
54+
if: ${{ (!inputs.is_scheduled_event) || (inputs.is_scheduled_event && inputs.deploy_on_schedule) }}
4555
runs-on: ${{ inputs.runner || 'ubuntu-22.04' }}
4656
services:
4757
registry:
@@ -198,7 +208,7 @@ jobs:
198208
199209
200210
- name: ghcr.io - move tag to production
201-
if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH == 'true' }}
211+
if: ${{ env.DEPLOY_IMAGES == 'true' && (inputs.is_scheduled_event == 'true' || env.MAIN_BRANCH == 'true') }}
202212
run: |
203213
msg="Update tag (dev_${{ env.IMG }} --> ${{ env.IMG }})"
204214
line="${msg//?/=}"
@@ -226,7 +236,7 @@ jobs:
226236
docker://quay.io/mariadb-foundation/${{ env.REPO }}:dev_${{ env.IMG }}
227237
228238
- name: quay.io - move tag to production
229-
if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH =='true' }}
239+
if: ${{ env.DEPLOY_IMAGES == 'true' && (inputs.is_scheduled_event == 'true' || env.MAIN_BRANCH == 'true')}}
230240
run: |
231241
msg="Update tag (dev_${{ env.IMG }} --> ${{ env.IMG }})"
232242
line="${msg//?/=}"

.github/workflows/build-debian-based.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ on:
2424
- .github/workflows/bbw_build_container_template.yml
2525

2626
workflow_call:
27+
inputs:
28+
is_scheduled_event:
29+
required: false
30+
type: boolean
31+
default: false
2732

2833
jobs:
2934
build-images:
@@ -65,12 +70,14 @@ jobs:
6570
platforms: linux/amd64, linux/arm64/v8, linux/ppc64le
6671
branch: 11.4
6772
nogalera: false
73+
deploy_on_schedule: true
6874

6975
- image: debian:sid
7076
platforms: linux/386
7177
branch: 11.4
7278
tag: debiansid-386
7379
nogalera: false
80+
deploy_on_schedule: true
7481

7582
- image: ubuntu:22.04
7683
platforms: linux/amd64, linux/arm64/v8, linux/ppc64le, linux/s390x
@@ -95,4 +102,6 @@ jobs:
95102
tag: ${{ matrix.tag }}
96103
branch: ${{ matrix.branch }}
97104
nogalera: ${{ matrix.nogalera }}
105+
is_scheduled_event: ${{ inputs.is_scheduled_event || false }}
106+
deploy_on_schedule: ${{ matrix.deploy_on_schedule || false }}
98107
secrets: inherit

.github/workflows/build-workflow-dispatcher.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Dispatch all build container images workflows
22

33
on:
4+
schedule:
5+
- cron: '0 3 3 * *' # Third of the month
6+
47
workflow_dispatch:
58
inputs:
69
build-centospip-based:
@@ -50,9 +53,11 @@ jobs:
5053
uses: ./.github/workflows/build-centos.pip-based.yml
5154
secrets: inherit
5255
build-debian-based:
53-
if: ${{ inputs.build-debian-based }}
56+
if: ${{ inputs.build-debian-based || github.event_name == 'schedule'}}
5457
uses: ./.github/workflows/build-debian-based.yml
5558
secrets: inherit
59+
with:
60+
is_scheduled_event: ${{ github.event_name == 'schedule' }}
5661
build-debian-aocc-based:
5762
if: ${{ inputs.build-debian-aocc-based }}
5863
uses: ./.github/workflows/build-debian.aocc-based.yml

0 commit comments

Comments
 (0)