From bc15fcc5518974f1008133e2272f815618caf8c9 Mon Sep 17 00:00:00 2001 From: caipira113 Date: Thu, 21 Mar 2024 00:11:30 +0900 Subject: [PATCH] CI, Fix --- .github/workflows/docker.yml | 69 +++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 9e76822..c347304 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Get commit sha run: echo "COMMIT_SHA=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV - name: Get os name @@ -32,22 +32,22 @@ jobs: echo "${{ secrets.SSH_PRIVATE_KEY }}" | ssh-add - - name: Set up Docker Buildx for amd64 if: matrix.platform == 'linux/amd64' - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 with: platforms: ${{ matrix.platform }} - name: Set up Docker Buildx for arm64 if: matrix.platform == 'linux/arm64' env: SSH_AUTH_SOCK: /tmp/ssh_agent.sock - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 with: platforms: ${{ matrix.platform }} endpoint: ssh://${{ secrets.ARM_NODE_USER }}@${{ secrets.ARM_NODE_ADDR }}:${{ secrets.ARM_NODE_PORT }} - - name: Build and Push + - name: Build and export id: buildx env: SSH_AUTH_SOCK: /tmp/ssh_agent.sock - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . provenance: false @@ -55,18 +55,18 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max # image to tar - outputs: type=local,dest=./${{ env.OS }}-image.tar + outputs: type=tar,dest=./${{ env.OS }}-image.tar - name: Image ID Output - run: echo "${{ steps.buildx.outputs.imageid }}" > "${{ env.OS }}-image.id" + run: echo "${{ steps.buildx.outputs.imageid }}" > "${{ env.OS }}-image-id.txt" - name: Upload image id uses: actions/upload-artifact@v4 with: - name: ${{ env.OS }}-image-id - path: ${{ env.OS }}-image.id + name: ${{ env.OS }}-image-id.txt + path: ${{ env.OS }}-image-id.txt - name: Upload image tar uses: actions/upload-artifact@v4 with: - name: ${{ env.OS }}-image + name: ${{ env.OS }}-image.tar path: ${{ env.OS }}-image.tar tag-merge: permissions: @@ -77,62 +77,65 @@ jobs: needs: build steps: - - name: Download image id + - name: Download image id (amd64) uses: actions/download-artifact@v4 with: - name: amd64-image.id - path: amd64-image.id - - name: Download image id + name: amd64-image-id.txt + - name: Download image id (arm64) uses: actions/download-artifact@v4 with: - name: arm64-image.id - path: arm64-image.id - - name: Download image tar + name: arm64-image-id.txt + - name: Download image tar (amd64) uses: actions/download-artifact@v4 with: - name: amd64-image - path: amd64-image.tar - - name: Download image tar + name: amd64-image.tar + - name: Download image tar (arm64) uses: actions/download-artifact@v4 with: - name: arm64-image - path: arm64-image.tar + name: arm64-image.tar - name: Set image id output id: imageid run: | - echo "amd64-image=$(cat amd64-image.id)" >> $GITHUB_OUTPUT - echo "arm64-image=$(cat arm64-image.id)" >> $GITHUB_OUTPUT + echo "amd64-image=$(cat amd64-image-id)" >> $GITHUB_OUTPUT + echo "arm64-image=$(cat arm64-image-id)" >> $GITHUB_OUTPUT - name: Authenticate to Google Cloud id: auth - uses: google-github-actions/auth@v1 + uses: google-github-actions/auth@v2 with: token_format: access_token workload_identity_provider: ${{ secrets.IDENTITY_PROVIDER }} service_account: ${{ secrets.SERVICE_ACCOUNT }} - name: Login to Artifact Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ secrets.ARTIFACT_REGISTRY }} username: oauth2accesstoken password: ${{ steps.auth.outputs.access_token }} - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Load image - run: docker import ubuntu-image.tar + run: docker import amd64-image.tar - name: Load image - run: docker import macos-image.tar + run: docker import arm64-image.tar - name: Tag run: | docker manifest create \ - ${{ secrets.ARTIFACT_REGISTRY }}/libnare/${{ github.event.repository.name }}/${{ github.ref_name }}:${{ github.sha }} \ + ${{ secrets.ARTIFACT_REGISTRY }}/libnare/${{ github.event.repository.name }}/${{ github.ref_name }}:latest \ ${{ steps.imageid.outputs.amd64-image }} \ ${{ steps.imageid.outputs.arm64-image }} docker manifest annotate --arch amd64 \ - ${{ secrets.ARTIFACT_REGISTRY }}/libnare/${{ github.event.repository.name }}/${{ github.ref_name }}:${{ github.sha }} \ + ${{ secrets.ARTIFACT_REGISTRY }}/libnare/${{ github.event.repository.name }}/${{ github.ref_name }}:latest \ ${{ steps.imageid.outputs.amd64-image }} docker manifest annotate --arch arm64 \ - ${{ secrets.ARTIFACT_REGISTRY }}/libnare/${{ github.event.repository.name }}/${{ github.ref_name }}:${{ github.sha }} \ + ${{ secrets.ARTIFACT_REGISTRY }}/libnare/${{ github.event.repository.name }}/${{ github.ref_name }}:latest \ ${{ steps.imageid.outputs.arm64-image }} - name: Push - run: docker manifest push ${{ secrets.ARTIFACT_REGISTRY }}/libnare/${{ github.event.repository.name }}/${{ github.ref_name }}:${{ github.sha }} \ No newline at end of file + run: docker manifest push ${{ secrets.ARTIFACT_REGISTRY }}/libnare/${{ github.event.repository.name }}/${{ github.ref_name }}:latest + - name: Summary + run: | + echo "Job completed! 🎉" >> $GITHUB_STEP_SUMMARY + echo "Image pushed to `${{ secrets.ARTIFACT_REGISTRY }}/libnare/${{ github.event.repository.name }}/${{ github.ref_name }}:latest`" >> $GITHUB_STEP_SUMMARY + echo "## Details" >> $GITHUB_STEP_SUMMARY + echo "linux/arm64: `${{ steps.imageid.outputs.arm64-image }}`" >> $GITHUB_STEP_SUMMARY + echo "linux/amd64: `${{ steps.imageid.outputs.amd64-image }}`" >> $GITHUB_STEP_SUMMARY \ No newline at end of file