From f7a7ddfc1dece9c64b20ddf1c307cb1024fb713f Mon Sep 17 00:00:00 2001 From: Till0196 <16399842+Till0196@users.noreply.github.com> Date: Tue, 12 Nov 2024 21:16:48 +0900 Subject: [PATCH] fix-ci --- .github/workflows/ci.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33cea05..adff3a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,9 @@ on: name: CI +env: + REGISTRY_IMAGE: ghcr.io/${{ github.repository }} + jobs: build-image: name: Build and push image @@ -42,11 +45,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ghcr.io/${{ github.repository }} - tags: | - type=ref,prefix=pr-,suffix=,event=pr - type=sha - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} + images: ${{ env.REGISTRY_IMAGE }} - name: Set up Buildx uses: docker/setup-buildx-action@v3 @@ -63,16 +62,15 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and Push + - name: Build and push by digest id: build uses: docker/build-push-action@v6 with: context: . push: ${{ github.event_name != 'pull_request' }} - outputs: type=image,name=ghcr.io/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true platforms: ${{ matrix.platform }} - tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true cache-from: type=gha cache-to: type=gha,mode=max @@ -91,6 +89,7 @@ jobs: retention-days: 1 merge: + if: github.event_name != 'pull_request' runs-on: ubuntu-latest needs: - build-image @@ -109,7 +108,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ghcr.io/${{ github.repository }} + images: ${{ env.REGISTRY_IMAGE }} tags: | type=ref,prefix=pr-,suffix=,event=pr type=sha @@ -126,8 +125,8 @@ jobs: working-directory: /tmp/digests run: | docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf 'ghcr.io/${{ github.repository }}@sha256:%s ' *) + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - name: Inspect image run: | - docker buildx imagetools inspect ghcr.io/${{ github.repository }}:${{ steps.meta.outputs.version }} + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}