From 15aef30867766f3344f4b8b9b8ad2642a0bcc260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tuna2134=40=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA?= =?UTF-8?q?=E8=A1=9B=E9=9A=8A?= Date: Mon, 20 Jan 2025 09:10:07 +0900 Subject: [PATCH] Update CI.yml --- .github/workflows/CI.yml | 65 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 117e96d..162cce0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -129,7 +129,7 @@ jobs: command: upload args: --non-interactive --skip-existing wheels-*/* - push-docker: + build-docker: runs-on: ${{ matrix.platform }} if: "startsWith(github.ref, 'refs/tags/')" permissions: @@ -155,7 +155,64 @@ jobs: uses: docker/build-push-action@v6 with: context: . - push: true - tags: | - ghcr.io/${{ github.repository }}:${{ matrix.tag }} file: docker/${{ matrix.tag }}.Dockerfile + labels: ${{ steps.meta.outputs.labels }} + outputs: type=image,"name=ghcr.io/tuna2134/sbv2-api",push-by-digest=true,name-canonical=true,push=true + + - name: Export digest + run: | + mkdir -p ${{ runner.temp }}/digests + digest="${{ steps.build.outputs.digest }}" + touch "${{ runner.temp }}/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-${{ env.PLATFORM_PAIR }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + + merge: + runs-on: ubuntu-latest + needs: + - build-docker + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digests-* + merge-multiple: true + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/tuna2134/sbv2-api + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Create manifest list and push + working-directory: ${{ runner.temp }}/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf 'ghcr.io/tuna2134/sbv2-api@sha256:%s ' *) + + - name: Inspect image + run: | + docker buildx imagetools inspect ghcr.io/tuna2134/sbv2-api:${{ steps.meta.outputs.version }}