Skip to content

Merge pull request #10 from wetfish/stage-testing #20

Merge pull request #10 from wetfish/stage-testing

Merge pull request #10 from wetfish/stage-testing #20

name: Docker Image Build
on:
# build when push to main or release happens
push:
branches:
- main
- release
# allow manual execution
workflow_dispatch:
env:
REGISTRY: ghcr.io
jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
# tag with latest (only on default branch)
# <branch>
# <pr #>
# <hash>
# <git tag>
# prod IF branch == release
# staging IF branch == main
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
type=raw,value=latest,priority=900,enable={{is_default_branch}}
type=raw,value=staging,priority=1000,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=prod,priority=1000,enable=${{ github.ref == format('refs/heads/{0}', 'release') }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}