on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main
    tags:
      - "v*"

jobs:
  build:
    timeout-minutes: 20
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - id: meta
        uses: docker/metadata-action@v3
        with:
          images: |
            ghcr.io/${{ github.repository }}
            mtsmfm/yaichi
          tags: |
            type=ref,event=branch
            type=ref,event=pr
            type=sha
            type=semver,pattern={{version}}
            type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
      - uses: docker/setup-qemu-action@v1
      - uses: docker/setup-buildx-action@v1
      - uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - uses: docker/login-action@v1
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - uses: docker/build-push-action@v2
        with:
          platforms: linux/amd64
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          cache-from: type=gha
          cache-to: type=gha,mode=max

Build and push via GitHub Actions
Build and push via GitHub Actions
