|
10 | 10 | JAVA_OPTS: "-Xmx4G"
|
11 | 11 | JVM_OPTS: "-Xmx4G"
|
12 | 12 | SBT_OPTS: "-Xmx4G"
|
| 13 | + REGISTRY_IMAGE: keynmol/sn-vcpkg |
13 | 14 |
|
14 | 15 | jobs:
|
15 | 16 | build:
|
@@ -144,38 +145,113 @@ jobs:
|
144 | 145 | SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
|
145 | 146 | SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
|
146 | 147 |
|
147 |
| - release_docker: |
148 |
| - name: Push Docker image to Docker Hub |
149 |
| - needs: [build] |
150 |
| - if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') |
| 148 | + docker: |
151 | 149 | runs-on: ubuntu-latest
|
| 150 | + strategy: |
| 151 | + fail-fast: false |
| 152 | + if: github.event_name == 'pull_request' |
152 | 153 | steps:
|
153 |
| - - name: Check out the repo |
| 154 | + - name: Checkout |
154 | 155 | uses: actions/checkout@v3
|
155 |
| - |
156 |
| - - name: Log in to Docker Hub |
157 |
| - uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a |
| 156 | + |
| 157 | + - name: Build |
| 158 | + id: build |
| 159 | + uses: docker/build-push-action@v4 |
158 | 160 | with:
|
159 |
| - username: ${{ secrets.DOCKERHUB_USERNAME }} |
160 |
| - password: ${{ secrets.DOCKERHUB_PASSWORD }} |
161 |
| - |
162 |
| - - name: Extract metadata (tags, labels) for Docker |
| 161 | + push: false |
| 162 | + file: ./modules/sn-vcpkg-docker/Dockerfile |
| 163 | + context: . |
| 164 | + outputs: type=image,name=${{ env.REGISTRY_IMAGE }} |
| 165 | + |
| 166 | + docker_release_build: |
| 167 | + runs-on: ubuntu-latest |
| 168 | + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') |
| 169 | + strategy: |
| 170 | + fail-fast: false |
| 171 | + matrix: |
| 172 | + platform: |
| 173 | + - linux/amd64 |
| 174 | + - linux/arm64 |
| 175 | + steps: |
| 176 | + - |
| 177 | + name: Checkout |
| 178 | + uses: actions/checkout@v3 |
| 179 | + - |
| 180 | + name: Docker meta |
163 | 181 | id: meta
|
164 |
| - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
| 182 | + uses: docker/metadata-action@v4 |
165 | 183 | with:
|
166 |
| - images: | |
167 |
| - keynmol/sn-vcpkg |
168 |
| - tags: | |
169 |
| - type=ref,event=branch |
170 |
| - type=ref,event=pr |
171 |
| - type=semver,pattern={{version}} |
172 |
| - type=sha |
173 |
| - |
174 |
| - - name: Build and push Docker image |
175 |
| - uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 |
| 184 | + images: ${{ env.REGISTRY_IMAGE }} |
| 185 | + - |
| 186 | + name: Set up QEMU |
| 187 | + uses: docker/setup-qemu-action@v2 |
| 188 | + - |
| 189 | + name: Set up Docker Buildx |
| 190 | + uses: docker/setup-buildx-action@v2 |
| 191 | + - |
| 192 | + name: Login to Docker Hub |
| 193 | + uses: docker/login-action@v2 |
| 194 | + with: |
| 195 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 196 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 197 | + - |
| 198 | + name: Build and push by digest |
| 199 | + id: build |
| 200 | + uses: docker/build-push-action@v4 |
176 | 201 | with:
|
177 | 202 | context: .
|
178 | 203 | file: ./modules/sn-vcpkg-docker/Dockerfile
|
179 |
| - push: true |
180 |
| - tags: ${{ steps.meta.outputs.tags }} |
| 204 | + platforms: ${{ matrix.platform }} |
181 | 205 | labels: ${{ steps.meta.outputs.labels }}
|
| 206 | + outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true |
| 207 | + - |
| 208 | + name: Export digest |
| 209 | + run: | |
| 210 | + mkdir -p /tmp/digests |
| 211 | + digest="${{ steps.build.outputs.digest }}" |
| 212 | + touch "/tmp/digests/${digest#sha256:}" |
| 213 | + - |
| 214 | + name: Upload digest |
| 215 | + uses: actions/upload-artifact@v3 |
| 216 | + with: |
| 217 | + name: digests |
| 218 | + path: /tmp/digests/* |
| 219 | + if-no-files-found: error |
| 220 | + retention-days: 1 |
| 221 | + |
| 222 | + docker_release_merge: |
| 223 | + runs-on: ubuntu-latest |
| 224 | + needs: [docker_release_build] |
| 225 | + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') |
| 226 | + steps: |
| 227 | + - |
| 228 | + name: Download digests |
| 229 | + uses: actions/download-artifact@v3 |
| 230 | + with: |
| 231 | + name: digests |
| 232 | + path: /tmp/digests |
| 233 | + - |
| 234 | + name: Set up Docker Buildx |
| 235 | + uses: docker/setup-buildx-action@v2 |
| 236 | + - |
| 237 | + name: Docker meta |
| 238 | + id: meta |
| 239 | + uses: docker/metadata-action@v4 |
| 240 | + with: |
| 241 | + images: ${{ env.REGISTRY_IMAGE }} |
| 242 | + - |
| 243 | + name: Login to Docker Hub |
| 244 | + uses: docker/login-action@v2 |
| 245 | + with: |
| 246 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 247 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 248 | + - |
| 249 | + name: Create manifest list and push |
| 250 | + working-directory: /tmp/digests |
| 251 | + run: | |
| 252 | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 253 | + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) |
| 254 | + - |
| 255 | + name: Inspect image |
| 256 | + run: | |
| 257 | + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |
0 commit comments