build multiple flavors at the same time. handle tags for branches
This commit is contained in:
parent
f1f2da2dd3
commit
25ae2c669c
|
@ -1,7 +1,7 @@
|
|||
name: Docker
|
||||
on:
|
||||
push:
|
||||
branches: [ main, sandbox ]
|
||||
branches: [ main, beta ]
|
||||
# Publish semver tags as releases.
|
||||
tags: [ 'v*.*.*' ]
|
||||
|
||||
|
@ -21,7 +21,9 @@ jobs:
|
|||
contents: read
|
||||
packages: write
|
||||
id-token: write
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
flavor: [main, sandbox]
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
@ -45,10 +47,15 @@ jobs:
|
|||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
flavor: |
|
||||
latest=${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
|
||||
# only latest if push has a tag and we're building the "main" flavor
|
||||
latest=${{ github.event_name == 'push' && matrix.flavor == 'main' && contains(github.ref, 'refs/tags/') }}
|
||||
tags: |
|
||||
type=ref,enable=true,event=branch
|
||||
type=ref,enable=true,event=tag
|
||||
# if this is a tag'd build, prefix it with the flavor (eg. main-v1.2.3 and sandbox-v1.2.3)
|
||||
type=ref,event=tag,prefix=${{ matrix.flavor }}-
|
||||
# if this is a main branch build, just tag it with the flavor (eg. main and sandbox)
|
||||
type=raw,value=${{ matrix.flavor }},enable=${{ github.ref_name == 'main' }}
|
||||
# if this is a (non main) branch build, tag it with the flavor and branch name (eg. main-branch and sandbox-branch)
|
||||
type=ref,event=branch,prefix=${{ matrix.flavor }}-,enable=${{ matrix.flavor != 'main' }}
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
# Build and push Docker image with Buildx (don't push on PR)
|
||||
# https://github.com/docker/build-push-action
|
||||
|
@ -63,4 +70,4 @@ jobs:
|
|||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
FASTEN_ENV=${{ github.ref_name == 'sandbox' && 'sandbox' || 'prod' }}
|
||||
FASTEN_ENV=${{ matrix.flavor == 'sandbox' && 'sandbox' || 'prod' }}
|
||||
|
|
Loading…
Reference in New Issue