Skip to content

Commit

Permalink
Update build-image.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
sinoru committed Feb 27, 2024
1 parent 2ad88b5 commit 8dd406e
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,42 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.docker-platforms }}
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-qemu-action@v3
- uses: docker/metadata-action@v5
id: meta
with:
platforms: ${{ matrix.docker-platforms }}
- uses: docker/setup-buildx-action@v3
images: ${{ env.DOCKER_IMAGE }}
- uses: docker/build-push-action@v5
id: build
with:
context: .
file: ./Dockerfile
platforms: ${{ matrix.docker-platforms }}
cache-from: type=gha,scope=$GITHUB_REF_NAME/${{ matrix.docker-platforms }}
cache-to: type=gha,scope=$GITHUB_REF_NAME/${{ matrix.docker-platforms }},mode=max
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.DOCKER_IMAGE }},push-by-digest=${{ github.event_name != 'pull_request' }},name-canonical=true,push=${{ github.event_name != 'pull_request' }}
- name: Export digest
id: digest
run: |
export DIGESTS_PATH="$RUNNER_TEMP/$(uuidgen)/digests"
echo "DIGESTS_PATH=$DIGESTS_PATH" >>${GITHUB_ENV}
mkdir -p $DIGESTS_PATH
digest="${{ steps.build.outputs.digest }}"
touch "$DIGESTS_PATH/${digest#sha256:}"
echo "digest=${digest#sha256:}" >> $GITHUB_OUTPUT
- name: Upload digest
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: digests
path: ${{ env.DIGESTS_PATH }}/*
if-no-files-found: error
retention-days: 1
name: ${{ steps.digest.outputs.digest }}
path: /dev/null
compression-level: 0
overwrite: true

mix:
if: github.event_name != 'pull_request'
Expand All @@ -79,19 +83,18 @@ jobs:
export DIGESTS_PATH="$RUNNER_TEMP/$(uuidgen)/digests"
echo "DIGESTS_PATH=$DIGESTS_PATH" >>${GITHUB_ENV}
- name: Download digests
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: digests
path: ${{ env.DIGESTS_PATH }}
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-buildx-action@v3
- run: echo "DOCKER_IMAGE=${DOCKER_IMAGE,,}" >>${GITHUB_ENV} # repository name must be lowercase
- uses: docker/metadata-action@v4
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.DOCKER_IMAGE }}
Expand Down

0 comments on commit 8dd406e

Please sign in to comment.