|
8 | 8 | env: |
9 | 9 | REGISTRY: ghcr.io |
10 | 10 | IMAGE: ghcr.io/${{ github.repository }} |
| 11 | + ROOK_IMAGE: ghcr.io/${{ github.repository }}-rook |
11 | 12 |
|
12 | 13 | jobs: |
13 | 14 | build: |
@@ -59,6 +60,103 @@ jobs: |
59 | 60 | if-no-files-found: error |
60 | 61 | retention-days: 1 |
61 | 62 |
|
| 63 | + build-rook: |
| 64 | + name: Build rook (${{ matrix.platform }}) |
| 65 | + runs-on: ${{ matrix.runner }} |
| 66 | + permissions: |
| 67 | + packages: write |
| 68 | + strategy: |
| 69 | + matrix: |
| 70 | + include: |
| 71 | + - platform: linux/amd64 |
| 72 | + runner: ubuntu-latest |
| 73 | + - platform: linux/arm64 |
| 74 | + runner: ubuntu-24.04-arm |
| 75 | + |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v4 |
| 78 | + |
| 79 | + - name: Log in to GHCR |
| 80 | + uses: docker/login-action@v3 |
| 81 | + with: |
| 82 | + registry: ${{ env.REGISTRY }} |
| 83 | + username: ${{ github.actor }} |
| 84 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 85 | + |
| 86 | + - name: Set up Docker Buildx |
| 87 | + uses: docker/setup-buildx-action@v3 |
| 88 | + |
| 89 | + - name: Build and push by digest |
| 90 | + id: build |
| 91 | + uses: docker/build-push-action@v5 |
| 92 | + with: |
| 93 | + context: . |
| 94 | + file: deploy/rook.Dockerfile |
| 95 | + platforms: ${{ matrix.platform }} |
| 96 | + outputs: type=image,name=${{ env.ROOK_IMAGE }},push-by-digest=true,name-canonical=true,push=true |
| 97 | + |
| 98 | + - name: Export digest |
| 99 | + run: | |
| 100 | + mkdir -p /tmp/rook-digests |
| 101 | + digest="${{ steps.build.outputs.digest }}" |
| 102 | + touch "/tmp/rook-digests/${digest#sha256:}" |
| 103 | +
|
| 104 | + - name: Upload digest |
| 105 | + uses: actions/upload-artifact@v4 |
| 106 | + with: |
| 107 | + name: rook-digest-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} |
| 108 | + path: /tmp/rook-digests/* |
| 109 | + if-no-files-found: error |
| 110 | + retention-days: 1 |
| 111 | + |
| 112 | + merge-rook: |
| 113 | + name: Merge and push rook manifest |
| 114 | + needs: build-rook |
| 115 | + runs-on: ubuntu-latest |
| 116 | + permissions: |
| 117 | + contents: write |
| 118 | + packages: write |
| 119 | + |
| 120 | + steps: |
| 121 | + - uses: actions/checkout@v4 |
| 122 | + with: |
| 123 | + fetch-depth: 0 |
| 124 | + |
| 125 | + - name: Download digests |
| 126 | + uses: actions/download-artifact@v4 |
| 127 | + with: |
| 128 | + path: /tmp/rook-digests |
| 129 | + pattern: rook-digest-* |
| 130 | + merge-multiple: true |
| 131 | + |
| 132 | + - name: Log in to GHCR |
| 133 | + uses: docker/login-action@v3 |
| 134 | + with: |
| 135 | + registry: ${{ env.REGISTRY }} |
| 136 | + username: ${{ github.actor }} |
| 137 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 138 | + |
| 139 | + - name: Set up Docker Buildx |
| 140 | + uses: docker/setup-buildx-action@v3 |
| 141 | + |
| 142 | + - name: Compute tags |
| 143 | + id: meta |
| 144 | + uses: docker/metadata-action@v5 |
| 145 | + with: |
| 146 | + images: ${{ env.ROOK_IMAGE }} |
| 147 | + tags: | |
| 148 | + type=sha,prefix=,format=short,enable=${{ github.ref_type == 'branch' }} |
| 149 | + type=raw,value=nightly,enable=${{ github.ref_type == 'branch' }} |
| 150 | + type=semver,pattern={{version}} |
| 151 | + type=raw,value=latest,enable=${{ github.ref_type == 'tag' }} |
| 152 | +
|
| 153 | + - name: Create and push manifest |
| 154 | + working-directory: /tmp/rook-digests |
| 155 | + run: | |
| 156 | + docker buildx imagetools create \ |
| 157 | + $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 158 | + $(printf '${{ env.ROOK_IMAGE }}@sha256:%s ' *) |
| 159 | +
|
62 | 160 | merge: |
63 | 161 | name: Merge and push manifest |
64 | 162 | needs: build |
|
0 commit comments