Daily build #457
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Github workflow that rebuilds already released images | |
name: Daily build | |
on: | |
schedule: | |
- cron: "0 1 * * 1-5" | |
- cron: "0 3 * * 1-5" | |
workflow_dispatch: | |
inputs: | |
image_repo: | |
type: choice | |
description: "Target image repository for built images" | |
default: mongodb/mongodb-atlas-kubernetes-operator-prerelease | |
required: true | |
options: | |
- mongodb/mongodb-atlas-kubernetes-operator-prerelease | |
- mongodb/mongodb-atlas-kubernetes-operator | |
jobs: | |
read-versions: | |
name: Read config file | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.images-matrix.outputs.matrix }} | |
platforms: ${{ steps.images-matrix.outputs.platforms }} | |
date: ${{ steps.set-date.outputs.date }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Read config file (daily-builds.json) | |
id: images-matrix | |
run: | | |
CONTENT=`cat ./daily-builds.json` | |
CONTENT="${CONTENT//'%'/'%25'}" | |
echo matrix=${CONTENT} >> $GITHUB_OUTPUT | |
- name: Set date | |
id: set-date | |
run: | | |
DATE=$(date +'%Y-%m-%d') | |
echo date=${DATE} >> $GITHUB_OUTPUT | |
build-and-publish-image: | |
runs-on: ubuntu-latest | |
env: | |
IMAGE_REPOSITORY: ${{ github.event.inputs.image_repo || 'mongodb/mongodb-atlas-kubernetes-operator' }} | |
QUAY_ROBOT_NAME: mongodb+mongodb_atlas_kubernetes | |
needs: | |
- read-versions | |
strategy: | |
matrix: | |
version: ${{ fromJSON(needs.read-versions.outputs.matrix).versions }} | |
steps: | |
- name: Print daily tag | |
id: daily-tag | |
run: | | |
DAILY_TAG="${{ matrix.version }}-${{needs.read-versions.outputs.date}}" | |
echo "daily-tag=${DAILY_TAG}" >> $GITHUB_OUTPUT | |
- name: Rebuild ${{matrix.version}} | |
run: | | |
echo "Building ${{matrix.version}} version" | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
ref: "v${{ matrix.version }}" | |
submodules: true | |
fetch-depth: 0 | |
- name: Upgrade build Makefile & Dockerfile # TODO: remove after version 1.9 is deprecated | |
run: | | |
git remote show origin | |
git checkout origin/${{ github.ref_name }} -- Makefile fast.Dockerfile scripts/version-check.sh scripts/module-path.sh | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: "${{ github.workspace }}/go.mod" | |
cache: false | |
- name: Setup cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }} | |
- name: Download go build dependencies | |
shell: bash | |
run: | | |
go mod download | |
- name: Build all platforms & check version | |
run: make all-platforms check-version VERSION=${{ matrix.version }} | |
- name: "Set up Docker Buildx" | |
uses: docker/setup-buildx-action@v3 | |
with: | |
platforms: ${{ fromJSON(needs.read-versions.outputs.matrix).platforms }} | |
- name: Login to docker registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to quay.io registry | |
uses: docker/login-action@v3 | |
with: | |
registry: quay.io | |
username: ${{ env.QUAY_ROBOT_NAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
- name: Build and push operator to the DockerHub (daily-tag & release-tag) | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: fast.Dockerfile | |
build-args: VERSION=${{ matrix.version }} | |
platforms: ${{ fromJSON(needs.read-versions.outputs.matrix).platforms }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
push: true | |
sbom: true | |
tags: | | |
${{ env.IMAGE_REPOSITORY }}:${{ steps.daily-tag.outputs.daily-tag }} | |
${{ env.IMAGE_REPOSITORY }}:${{ matrix.version }} | |
quay.io/${{ env.IMAGE_REPOSITORY }}:${{ steps.daily-tag.outputs.daily-tag }} | |
quay.io/${{ env.IMAGE_REPOSITORY }}:${{ matrix.version }} |