Skip to content

Commit

Permalink
update build push action (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger authored Nov 15, 2023
1 parent 1d45441 commit 24bfa53
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,30 @@ jobs:
df -h
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=ghcr.io/${{ github.repository_owner }}/${{ matrix.context }}
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository_owner }}/${{ matrix.context }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
type=sha
- uses: docker/build-push-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
context: ${{ matrix.context }}
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ matrix.context }}:buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ matrix.context }}:buildcache,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ matrix.context }}:buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ matrix.context }}:buildcache,mode=max

0 comments on commit 24bfa53

Please sign in to comment.