|
| 1 | +--- |
| 2 | +name: bbw-build-container-srpm |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - 'main' |
| 8 | + - 'dev' |
| 9 | + paths: |
| 10 | + - 'ci_build_images/srpm.Dockerfile' |
| 11 | + pull_request: |
| 12 | + paths: |
| 13 | + - 'ci_build_images/srpm.Dockerfile' |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + runs-on: ubuntu-24.04 |
| 19 | + services: |
| 20 | + registry: |
| 21 | + image: registry:2 |
| 22 | + ports: |
| 23 | + - 5000:5000 |
| 24 | + name: ${{ matrix.image }} (${{ matrix.tag }} ${{ matrix.platforms }}) |
| 25 | + strategy: |
| 26 | + fail-fast: false |
| 27 | + matrix: |
| 28 | + include: |
| 29 | + - dockerfile: srpm.Dockerfile |
| 30 | + image: fedora:41 |
| 31 | + tag: fedora41-srpm |
| 32 | + platforms: linux/amd64, linux/arm64/v8 |
| 33 | + |
| 34 | + - dockerfile: srpm.Dockerfile |
| 35 | + image: fedora:42 |
| 36 | + tag: fedora42-srpm |
| 37 | + platforms: linux/amd64, linux/arm64/v8 |
| 38 | + |
| 39 | + - dockerfile: srpm.Dockerfile |
| 40 | + image: registry.access.redhat.com/ubi7 |
| 41 | + tag: rhel7-srpm |
| 42 | + platforms: linux/amd64 |
| 43 | + |
| 44 | + - dockerfile: srpm.Dockerfile |
| 45 | + image: registry.access.redhat.com/ubi8 |
| 46 | + tag: rhel8-srpm |
| 47 | + platforms: linux/amd64, linux/arm64/v8, linux/ppc64le |
| 48 | + |
| 49 | + - dockerfile: srpm.Dockerfile |
| 50 | + image: registry.access.redhat.com/ubi9 |
| 51 | + tag: rhel9-srpm |
| 52 | + platforms: linux/amd64, linux/arm64/v8, linux/ppc64le |
| 53 | + |
| 54 | + - dockerfile: srpm.Dockerfile |
| 55 | + image: registry.access.redhat.com/ubi10 |
| 56 | + tag: rhel10-srpm |
| 57 | + platforms: linux/amd64, linux/arm64/v8, linux/ppc64le |
| 58 | + |
| 59 | + - dockerfile: srpm.Dockerfile |
| 60 | + image: quay.io/centos/centos:stream9 |
| 61 | + tag: centosstream9-srpm |
| 62 | + platforms: linux/amd64, linux/arm64/v8, linux/ppc64le |
| 63 | + |
| 64 | + - dockerfile: srpm.Dockerfile |
| 65 | + image: quay.io/centos/centos:stream10 |
| 66 | + tag: centosstream10-srpm |
| 67 | + platforms: linux/amd64, linux/arm64/v8, linux/ppc64le |
| 68 | + |
| 69 | + - dockerfile: srpm.Dockerfile |
| 70 | + image: opensuse/leap:15.6 |
| 71 | + tag: opensuse1506-srpm |
| 72 | + platforms: linux/amd64 |
| 73 | + |
| 74 | + - dockerfile: srpm.Dockerfile |
| 75 | + image: registry.suse.com/bci/bci-base:15.6 |
| 76 | + tag: sles1506-srpm |
| 77 | + platforms: linux/amd64 |
| 78 | + |
| 79 | + |
| 80 | + env: |
| 81 | + DEPLOY_IMAGES: false |
| 82 | + MAIN_BRANCH: false |
| 83 | + WORKDIR: ci_build_images |
| 84 | + |
| 85 | + steps: |
| 86 | + - name: Enable Production release - no rebuild |
| 87 | + run: echo "MAIN_BRANCH=true" >> $GITHUB_ENV |
| 88 | + if: github.ref == 'refs/heads/main' |
| 89 | + |
| 90 | + - uses: actions/checkout@v4 |
| 91 | + - name: Set up env vars |
| 92 | + run: | |
| 93 | + set -vx |
| 94 | + echo "REPO=bb-worker" >>$GITHUB_ENV |
| 95 | +
|
| 96 | + - name: Generate Dockerfile and necessary files |
| 97 | + if: ${{ env.MAIN_BRANCH == 'false' }} |
| 98 | + run: | |
| 99 | + cd ${{ env.WORKDIR }} |
| 100 | + cat ${{ matrix.dockerfile }} >$GITHUB_WORKSPACE/Dockerfile |
| 101 | +
|
| 102 | + - name: Check Dockerfile with hadolint |
| 103 | + if: ${{ env.MAIN_BRANCH == 'false' }} |
| 104 | + run: | |
| 105 | + docker run -i -v $(pwd):/mnt -w /mnt ghcr.io/hadolint/hadolint:latest hadolint /mnt/Dockerfile |
| 106 | +
|
| 107 | + - name: Install qemu-user-static |
| 108 | + if: ${{ env.MAIN_BRANCH == 'false' }} |
| 109 | + run: | |
| 110 | + sudo apt-get update |
| 111 | + sudo apt-get install -y qemu-user-static |
| 112 | +
|
| 113 | + - name: Build image |
| 114 | + if: ${{ env.MAIN_BRANCH == 'false' }} |
| 115 | + run: | |
| 116 | + podman manifest create ${{ env.REPO }}:${{ matrix.tag }} |
| 117 | + for arch in $(echo ${{ matrix.platforms }} | sed 's/,/ /g'); do |
| 118 | + msg="Build $arch:" |
| 119 | + line="${msg//?/=}" |
| 120 | + printf "\n${line}\n${msg}\n${line}\n" |
| 121 | + podman buildx build --tag ${{ env.REPO }}:${{ matrix.tag }}-${arch//\//-} \ |
| 122 | + --platform $arch \ |
| 123 | + --manifest ${{ env.REPO }}:${{ matrix.tag }} \ |
| 124 | + -f $GITHUB_WORKSPACE/Dockerfile \ |
| 125 | + --build-arg BASE_IMAGE=${{ matrix.image }} |
| 126 | + done |
| 127 | + podman images |
| 128 | +
|
| 129 | + - name: Push images to local registry |
| 130 | + if: ${{ env.MAIN_BRANCH == 'false'}} |
| 131 | + run: | |
| 132 | + podman manifest push --tls-verify=0 \ |
| 133 | + --all ${{ env.REPO }}:${{ matrix.tag }} \ |
| 134 | + docker://localhost:5000/${{ env.REPO }}:${{ matrix.tag }} |
| 135 | +
|
| 136 | + - name: Check for registry credentials |
| 137 | + run: | |
| 138 | + missing=() |
| 139 | + [[ -n "${{ secrets.QUAY_USER }}" ]] || missing+=(QUAY_USER) |
| 140 | + [[ -n "${{ secrets.QUAY_TOKEN }}" ]] || missing+=(QUAY_TOKEN) |
| 141 | + for i in "${missing[@]}"; do |
| 142 | + echo "Missing github secret: $i" |
| 143 | + done |
| 144 | + if (( ${#missing[@]} == 0 )); then |
| 145 | + echo "DEPLOY_IMAGES=true" >> $GITHUB_ENV |
| 146 | + else |
| 147 | + echo "Not pushing images to registry" |
| 148 | + fi |
| 149 | +
|
| 150 | + - name: Login to ghcr.io |
| 151 | + if: ${{ env.DEPLOY_IMAGES == 'true' }} |
| 152 | + uses: docker/login-action@v2 |
| 153 | + with: |
| 154 | + registry: ghcr.io |
| 155 | + username: ${{ github.actor }} |
| 156 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 157 | + |
| 158 | + - name: ghcr.io - push dev tag |
| 159 | + if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH == 'false' }} |
| 160 | + run: | |
| 161 | + msg="Push docker image to ghcr.io (${{ matrix.tag }})" |
| 162 | + line="${msg//?/=}" |
| 163 | + printf "\n${line}\n${msg}\n${line}\n" |
| 164 | + skopeo copy --all --src-tls-verify=0 \ |
| 165 | + docker://localhost:5000/${{ env.REPO }}:${{ matrix.tag }} \ |
| 166 | + docker://ghcr.io/${GITHUB_REPOSITORY,,}/${{ env.REPO }}:dev_${{ matrix.tag }} |
| 167 | +
|
| 168 | +
|
| 169 | + - name: ghcr.io - move tag to production |
| 170 | + if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH == 'true' }} |
| 171 | + run: | |
| 172 | + msg="Update tag (dev_${{ matrix.tag }} --> ${{ matrix.tag }})" |
| 173 | + line="${msg//?/=}" |
| 174 | + printf "\n${line}\n${msg}\n${line}\n" |
| 175 | + skopeo copy --all --src-tls-verify=0 \ |
| 176 | + docker://ghcr.io/${GITHUB_REPOSITORY,,}/${{ env.REPO }}:dev_${{ matrix.tag }} \ |
| 177 | + docker://ghcr.io/${GITHUB_REPOSITORY,,}/${{ env.REPO }}:${{ matrix.tag }} |
| 178 | +
|
| 179 | + - name: Login to quay.io |
| 180 | + if: ${{ env.DEPLOY_IMAGES == 'true' }} |
| 181 | + uses: docker/login-action@v2 |
| 182 | + with: |
| 183 | + registry: quay.io |
| 184 | + username: ${{ secrets.QUAY_USER }} |
| 185 | + password: ${{ secrets.QUAY_TOKEN }} |
| 186 | + |
| 187 | + - name: quay.io - push dev tag |
| 188 | + if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH == 'false' }} |
| 189 | + run: | |
| 190 | + msg="Push docker image to quay.io (${{ matrix.tag }})" |
| 191 | + line="${msg//?/=}" |
| 192 | + printf "\n${line}\n${msg}\n${line}\n" |
| 193 | + skopeo copy --all --src-tls-verify=0 \ |
| 194 | + docker://localhost:5000/${{ env.REPO }}:${{ matrix.tag }} \ |
| 195 | + docker://quay.io/mariadb-foundation/${{ env.REPO }}:dev_${{ matrix.tag }} |
| 196 | +
|
| 197 | + - name: quay.io - move tag to production |
| 198 | + if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH =='true' }} |
| 199 | + run: | |
| 200 | + msg="Update tag (dev_${{ matrix.tag }} --> ${{ matrix.tag }})" |
| 201 | + line="${msg//?/=}" |
| 202 | + printf "\n${line}\n${msg}\n${line}\n" |
| 203 | + skopeo copy --all --src-tls-verify=0 \ |
| 204 | + docker://quay.io/mariadb-foundation/${{ env.REPO }}:dev_${{ matrix.tag }} \ |
| 205 | + docker://quay.io/mariadb-foundation/${{ env.REPO }}:${{ matrix.tag }} |
0 commit comments