|
| 1 | +name: Build chunkah-staged bootc base images |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - 'staged-images/**' |
| 8 | + - '.github/workflows/build-staged-images.yml' |
| 9 | + schedule: |
| 10 | + # Rebuild weekly to pick up upstream base image updates |
| 11 | + - cron: '0 6 * * 1' |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +env: |
| 19 | + REGISTRY: ghcr.io |
| 20 | + |
| 21 | +jobs: |
| 22 | + # Read sources.json and generate matrices for downstream jobs. |
| 23 | + generate-matrix: |
| 24 | + name: Generate matrix |
| 25 | + runs-on: ubuntu-24.04 |
| 26 | + outputs: |
| 27 | + mirror: ${{ steps.matrix.outputs.mirror }} |
| 28 | + build: ${{ steps.matrix.outputs.build }} |
| 29 | + manifest: ${{ steps.matrix.outputs.manifest }} |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v6 |
| 32 | + - uses: extractions/setup-just@v3 |
| 33 | + - id: matrix |
| 34 | + run: | |
| 35 | + echo "mirror=$(just staged-images/ci-mirror-matrix)" >> "$GITHUB_OUTPUT" |
| 36 | + echo "build=$(just staged-images/ci-matrix)" >> "$GITHUB_OUTPUT" |
| 37 | + echo "manifest=$(just staged-images/ci-manifest-matrix)" >> "$GITHUB_OUTPUT" |
| 38 | + |
| 39 | + # Mirror upstream source images to GHCR so we have our own copy. |
| 40 | + # Upstream registries (quay.io) may delete old manifests, breaking |
| 41 | + # digest-pinned pulls. |
| 42 | + mirror: |
| 43 | + name: Mirror ${{ matrix.name }}:${{ matrix.tag }} |
| 44 | + needs: generate-matrix |
| 45 | + runs-on: ubuntu-24.04 |
| 46 | + permissions: |
| 47 | + contents: read |
| 48 | + packages: write |
| 49 | + strategy: |
| 50 | + fail-fast: false |
| 51 | + matrix: ${{ fromJson(needs.generate-matrix.outputs.mirror) }} |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v6 |
| 54 | + - uses: bootc-dev/actions/bootc-ubuntu-setup@main |
| 55 | + - name: Log in to GHCR |
| 56 | + run: | |
| 57 | + echo "${{ secrets.GITHUB_TOKEN }}" | \ |
| 58 | + podman login -u "${{ github.actor }}" --password-stdin ${{ env.REGISTRY }} |
| 59 | + - name: Mirror image |
| 60 | + run: just staged-images/mirror ${{ matrix.name }}-${{ matrix.tag }} |
| 61 | + env: |
| 62 | + REGISTRY_OWNER: ${{ github.repository_owner }} |
| 63 | + |
| 64 | + build: |
| 65 | + name: Build ${{ matrix.name }}:${{ matrix.tag }} (${{ matrix.arch }}) |
| 66 | + needs: [generate-matrix, mirror] |
| 67 | + if: ${{ !cancelled() }} |
| 68 | + runs-on: ${{ matrix.runner }} |
| 69 | + permissions: |
| 70 | + contents: read |
| 71 | + packages: write |
| 72 | + strategy: |
| 73 | + fail-fast: false |
| 74 | + matrix: ${{ fromJson(needs.generate-matrix.outputs.build) }} |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v6 |
| 77 | + - uses: bootc-dev/actions/bootc-ubuntu-setup@main |
| 78 | + - name: Log in to GHCR |
| 79 | + run: | |
| 80 | + echo "${{ secrets.GITHUB_TOKEN }}" | \ |
| 81 | + podman login -u "${{ github.actor }}" --password-stdin ${{ env.REGISTRY }} |
| 82 | + - name: Build staged image |
| 83 | + run: just staged-images/build ${{ matrix.image_key }} |
| 84 | + env: |
| 85 | + SOURCE_FROM_MIRROR: "1" |
| 86 | + REGISTRY_OWNER: ${{ github.repository_owner }} |
| 87 | + - name: Push by digest |
| 88 | + id: push |
| 89 | + run: | |
| 90 | + digest=$(just staged-images/push ${{ matrix.image_key }}) |
| 91 | + echo "digest=${digest}" >> "$GITHUB_OUTPUT" |
| 92 | + env: |
| 93 | + REGISTRY_OWNER: ${{ github.repository_owner }} |
| 94 | + - name: Upload digest artifact |
| 95 | + run: | |
| 96 | + mkdir -p "${{ runner.temp }}/digests" |
| 97 | + echo "${{ steps.push.outputs.digest }}" > "${{ runner.temp }}/digests/${{ matrix.arch }}" |
| 98 | + - uses: actions/upload-artifact@v7 |
| 99 | + with: |
| 100 | + name: staged-digests-${{ matrix.name }}-${{ matrix.tag }}-${{ matrix.arch }} |
| 101 | + path: ${{ runner.temp }}/digests/* |
| 102 | + if-no-files-found: error |
| 103 | + retention-days: 1 |
| 104 | + |
| 105 | + manifest: |
| 106 | + name: Manifest ${{ matrix.name }}:${{ matrix.tag }} |
| 107 | + needs: [generate-matrix, build] |
| 108 | + if: ${{ !cancelled() }} |
| 109 | + runs-on: ubuntu-24.04 |
| 110 | + permissions: |
| 111 | + contents: read |
| 112 | + packages: write |
| 113 | + strategy: |
| 114 | + fail-fast: false |
| 115 | + matrix: ${{ fromJson(needs.generate-matrix.outputs.manifest) }} |
| 116 | + steps: |
| 117 | + - uses: bootc-dev/actions/bootc-ubuntu-setup@main |
| 118 | + - uses: bootc-dev/actions/create-manifest@main |
| 119 | + with: |
| 120 | + image: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.name }} |
| 121 | + tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.name }}:${{ matrix.tag }} |
| 122 | + artifact-pattern: staged-digests-${{ matrix.name }}-${{ matrix.tag }}-* |
| 123 | + registry-login-env: 'false' |
0 commit comments