chore: improve tags with docker/metadata action

release-0.0
Meng Zhang 2023-08-31 09:35:29 +08:00
parent c44a9c7195
commit 26fc0e7e64
1 changed files with 16 additions and 9 deletions

View File

@ -53,17 +53,26 @@ jobs:
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
- name: Generate tag name
env:
REF_NAME: ${{ github.ref_name }}
run: |
echo "TAG_NAME=$(echo $REF_NAME | sed 's/main/nightly/g' | sed 's/^v//g')" >>${GITHUB_ENV}
- uses: int128/docker-build-cache-config-action@v1
id: cache
with:
image: ghcr.io/${{ env.IMAGE_NAME }}/cache
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ env.IMAGE_NAME }}
${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule,pattern=nightly
type=schedule,pattern={{date 'YYYYMMDD'}}
type=match,pattern=^v\d+.\d+.\d+$,value=latest
type=match,pattern=v(.*)
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
@ -73,9 +82,7 @@ jobs:
file: Dockerfile
push: true
context: .
tags: |
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.TAG_NAME }}
${{ env.IMAGE_NAME }}:${{ env.TAG_NAME }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: ${{ steps.cache.outputs.cache-from }}
cache-to: ${{ steps.cache.outputs.cache-to }}