wg-gen-web/.github/workflows/dockerimage.yml

60 lines
1.8 KiB
YAML

name: Docker Build
on:
pull_request:
branches:
- master
push:
branches:
- master
tags:
- 'v*.*.*'
env:
IMAGE_NAME: ${{ vars.IMAGE_NAME || github.repository }}
IMAGE_PLATFORMS: ${{ vars.IMAGE_PLATFORMS || 'linux/amd64,linux/arm64,linux/arm/v7' }}
REGISTRY: ${{ vars.REGISTRY_NAME || secrets.REGISTRY_NAME || 'docker.io' }}
jobs:
docker:
runs-on: ubuntu-latest
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4
# https://github.com/docker/login-action
- uses: docker/login-action@v3
if: ${{ github.event_name != 'pull_request' }}
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_LOGIN_USERNAME || secrets.REGISTRY_USERNAME || github.actor }}
password: ${{ secrets.DOCKER_LOGIN_PASSWORD || secrets.REGISTRY_PASSWORD || github.token }}
# https://github.com/docker/setup-buildx-action
- uses: docker/setup-buildx-action@v3
# https://github.com/docker/setup-qemu-action
- uses: docker/setup-qemu-action@v3
# https://github.com/docker/metadata-action
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
type=sha
# https://github.com/docker/build-push-action
- uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ env.IMAGE_PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: COMMIT=${{ github.sha }}