|
| 1 | +name: Build all images |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + |
| 7 | +defaults: |
| 8 | + run: |
| 9 | + shell: bash |
| 10 | + |
| 11 | +jobs: |
| 12 | + define-matrix: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + outputs: |
| 15 | + ubuntus: ${{ steps.distros.outputs.ubuntus }} |
| 16 | + debians: ${{ steps.distros.outputs.debians }} |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + submodules: true |
| 21 | + - name: Define Distros |
| 22 | + id: distros |
| 23 | + run: | |
| 24 | + echo "ubuntus=[$(awk -F= '/UBUNTU_DISTROS/{print $2}' ./internal/lib/distro_info.sh | sed -e 's/ /", "/g')]" >> "$GITHUB_OUTPUT" |
| 25 | + echo "debians=[$(awk -F= '/DEBIAN_DISTROS/{print $2}' ./internal/lib/distro_info.sh | sed -e 's/ /", "/g')]" >> "$GITHUB_OUTPUT" |
| 26 | +
|
| 27 | + build-buildbox: |
| 28 | + strategy: |
| 29 | + fail-fast: false |
| 30 | + matrix: |
| 31 | + distro: ${{ fromJSON(needs.define-matrix.outputs.ubuntus) }} |
| 32 | + arch: |
| 33 | + - platform: linux/amd64 |
| 34 | + runner: ubuntu-24.04 |
| 35 | + - platform: linux/arm64 |
| 36 | + runner: ubuntu-24.04-arm |
| 37 | + runs-on: ${{ matrix.arch.runner }} |
| 38 | + steps: |
| 39 | + - name: Prepare |
| 40 | + run: | |
| 41 | + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
| 42 | + echo "BUILDBOX_IMAGE_VERSION=$(./internal/lib/docker_image_info.sh buildbox_version)" >> $GITHUB_ENV |
| 43 | + echo "BUILDBOX_IMAGE_NAME=$(./internal/lib/docker_image_info.sh buildbox_name)" >> $GITHUB_ENV |
| 44 | + env: |
| 45 | + platform: ${{ matrix.arch.name }} |
| 46 | + |
| 47 | + - name: Docker meta |
| 48 | + id: meta |
| 49 | + uses: docker/metadata-action@v5 |
| 50 | + with: |
| 51 | + images: | |
| 52 | + ${{ env.BUILDBOX_IMAGE_NAME }} |
| 53 | +
|
| 54 | + - name: Login to GHCR |
| 55 | + uses: docker/login-action@v3 |
| 56 | + with: |
| 57 | + registry: ghcr.io |
| 58 | + username: ${{ github.actor }} |
| 59 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + |
| 61 | + - name: Set up QEMU |
| 62 | + uses: docker/setup-qemu-action@v3 |
| 63 | + |
| 64 | + - name: Set up Docker Buildx |
| 65 | + uses: docker/setup-buildx-action@v3 |
| 66 | + |
| 67 | + - name: Build and push by digest |
| 68 | + id: build |
| 69 | + uses: docker/build-push-action@v6 |
| 70 | + with: |
| 71 | + file: ./docker_images/buildbox/Dockerfile |
| 72 | + platforms: ${{ matrix.arch.platform }} |
| 73 | + labels: ${{ steps.meta.outputs.labels }} |
| 74 | + outputs: "type=image,name=${{ env.GHCR_REPO }},push-by-digest=true,name-canonical=true,push=true" |
| 75 | + |
| 76 | + - name: Export digest |
| 77 | + run: | |
| 78 | + mkdir -p /tmp/digests |
| 79 | + digest="${{ steps.build.outputs.digest }}" |
| 80 | + touch "/tmp/digests/${digest#sha256:}" |
| 81 | +
|
| 82 | + - name: Upload digest |
| 83 | + uses: actions/upload-artifact@v4 |
| 84 | + with: |
| 85 | + name: digests-${{ env.PLATFORM_PAIR }} |
| 86 | + path: /tmp/digests/* |
| 87 | + if-no-files-found: error |
| 88 | + retention-days: 1 |
| 89 | + |
| 90 | + build-ubuntus: |
| 91 | + needs: define-matrix |
| 92 | + strategy: |
| 93 | + fail-fast: false |
| 94 | + matrix: |
| 95 | + distro: ${{ fromJSON(needs.define-matrix.outputs.ubuntus) }} |
| 96 | + arch: |
| 97 | + - name: amd64 |
| 98 | + runner: ubuntu-24.04 |
| 99 | + - name: arm64 |
| 100 | + runner: ubuntu-24.04-arm |
| 101 | + runs-on: ${{ matrix.arch.runner }} |
| 102 | + steps: |
| 103 | + - name: Prepare |
| 104 | + run: | |
| 105 | + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
| 106 | + echo "TESTBOX_IMAGE_VERSION=$(./internal/lib/docker_image_info.sh testbox_version)" >> $GITHUB_ENV |
| 107 | + echo "TESTBOX_BASE_NAME=$(./internal/lib/docker_image_info.sh testbox_base_name)" >> $GITHUB_ENV |
| 108 | + echo "TESTBOX_IMAGE_NAME=${TESTBOX_BASE_NAME}_testbox_ubuntu_${{ matrix.distro }}" >> $GITHUB_ENV |
| 109 | + env: |
| 110 | + platform: linux/${{ matrix.arch.name }} |
| 111 | + |
| 112 | + - name: Docker meta |
| 113 | + id: meta |
| 114 | + uses: docker/metadata-action@v5 |
| 115 | + with: |
| 116 | + images: | |
| 117 | + ${{ env.TESTBOX_IMAGE_NAME }} |
| 118 | +
|
| 119 | + - name: Login to GHCR |
| 120 | + uses: docker/login-action@v3 |
| 121 | + with: |
| 122 | + registry: ghcr.io |
| 123 | + username: ${{ github.actor }} |
| 124 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 125 | + |
| 126 | + - name: Set up QEMU |
| 127 | + uses: docker/setup-qemu-action@v3 |
| 128 | + |
| 129 | + - name: Set up Docker Buildx |
| 130 | + uses: docker/setup-buildx-action@v3 |
| 131 | + |
| 132 | + - name: Build and push by digest |
| 133 | + id: build |
| 134 | + uses: docker/build-push-action@v6 |
| 135 | + with: |
| 136 | + file: ./docker_images/testbox-ubuntu-${{ matrix.distro }}/Dockerfile |
| 137 | + platforms: ${{ matrix.arch.platform }} |
| 138 | + labels: ${{ steps.meta.outputs.labels }} |
| 139 | + outputs: "type=image,name=${{ env.GHCR_REPO }},push-by-digest=true,name-canonical=true,push=true" |
| 140 | + |
| 141 | + - name: Export digest |
| 142 | + run: | |
| 143 | + mkdir -p /tmp/digests |
| 144 | + digest="${{ steps.build.outputs.digest }}" |
| 145 | + touch "/tmp/digests/${digest#sha256:}" |
| 146 | +
|
| 147 | + - name: Upload digest |
| 148 | + uses: actions/upload-artifact@v4 |
| 149 | + with: |
| 150 | + name: digests-${{ env.PLATFORM_PAIR }} |
| 151 | + path: /tmp/digests/* |
| 152 | + if-no-files-found: error |
| 153 | + retention-days: 1 |
| 154 | + |
| 155 | + build-debians: |
| 156 | + needs: define-matrix |
| 157 | + strategy: |
| 158 | + fail-fast: false |
| 159 | + matrix: |
| 160 | + distro: ${{ fromJSON(needs.define-matrix.outputs.debians) }} |
| 161 | + arch: |
| 162 | + - name: amd64 |
| 163 | + runner: debian-24.04 |
| 164 | + - name: arm64 |
| 165 | + runner: debian-24.04-arm |
| 166 | + runs-on: ${{ matrix.arch.runner }} |
| 167 | + steps: |
| 168 | + - name: Prepare |
| 169 | + run: | |
| 170 | + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
| 171 | + echo "TESTBOX_IMAGE_VERSION=$(./internal/lib/docker_image_info.sh testbox_version)" >> $GITHUB_ENV |
| 172 | + echo "TESTBOX_BASE_NAME=$(./internal/lib/docker_image_info.sh testbox_base_name)" >> $GITHUB_ENV |
| 173 | + echo "TESTBOX_IMAGE_NAME=${TESTBOX_BASE_NAME}_testbox_debian_${{ matrix.distro }}" >> $GITHUB_ENV |
| 174 | + env: |
| 175 | + platform: linux/${{ matrix.arch.name }} |
| 176 | + |
| 177 | + - name: Docker meta |
| 178 | + id: meta |
| 179 | + uses: docker/metadata-action@v5 |
| 180 | + with: |
| 181 | + images: | |
| 182 | + ${{ env.TESTBOX_IMAGE_NAME }} |
| 183 | +
|
| 184 | + - name: Login to GHCR |
| 185 | + uses: docker/login-action@v3 |
| 186 | + with: |
| 187 | + registry: ghcr.io |
| 188 | + username: ${{ github.actor }} |
| 189 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 190 | + |
| 191 | + - name: Set up QEMU |
| 192 | + uses: docker/setup-qemu-action@v3 |
| 193 | + |
| 194 | + - name: Set up Docker Buildx |
| 195 | + uses: docker/setup-buildx-action@v3 |
| 196 | + |
| 197 | + - name: Build and push by digest |
| 198 | + id: build |
| 199 | + uses: docker/build-push-action@v6 |
| 200 | + with: |
| 201 | + file: ./docker_images/testbox-debian-${{ matrix.distro }}/Dockerfile |
| 202 | + platforms: ${{ matrix.arch.platform }} |
| 203 | + labels: ${{ steps.meta.outputs.labels }} |
| 204 | + outputs: "type=image,name=${{ env.GHCR_REPO }},push-by-digest=true,name-canonical=true,push=true" |
| 205 | + |
| 206 | + - name: Export digest |
| 207 | + run: | |
| 208 | + mkdir -p /tmp/digests |
| 209 | + digest="${{ steps.build.outputs.digest }}" |
| 210 | + touch "/tmp/digests/${digest#sha256:}" |
| 211 | +
|
| 212 | + - name: Upload digest |
| 213 | + uses: actions/upload-artifact@v4 |
| 214 | + with: |
| 215 | + name: digests-${{ env.PLATFORM_PAIR }} |
| 216 | + path: /tmp/digests/* |
| 217 | + if-no-files-found: error |
| 218 | + retention-days: 1 |
0 commit comments