name: docker image

on:
  push:
    branches: [ master ]
    tags:
      - '*'
      - '!*rc*'

jobs:
  docker-image:

    runs-on: ubuntu-latest

    steps:
      - name: extract docker metadata
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: |
            arcan1s/ahriman
          tags: |
            type=ref,event=tag
            type=edge

      - name: setup QEMU
        uses: docker/setup-qemu-action@v1

      - name: setup docker buildx
        uses: docker/setup-buildx-action@v1

      - name: login to docker hub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: build an image and push
        uses: docker/build-push-action@v2
        with:
          push: true
          tags: ${{ steps.meta.outputs.tags }}
