# docker.yml
# Reusable workflow that builds a docker image for Libation.
---
name: docker

on:
  workflow_call:
    inputs:
      version:
        type: string
        description: 'Version number'
        required: true
    secrets:
      docker_username:
        required: true
      docker_token:
        required: true

env:
  DOCKER_IMAGE: ${{ secrets.docker_username }}/libation

jobs:
  docker:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2

      - name: Login to Docker Hub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.docker_username }}
          password: ${{ secrets.docker_token }}

      - name: Build and push
        uses: docker/build-push-action@v4
        with:
          push: true
          build-args: 'FOLDER_NAME=Linux-chardonnay'
          tags: ${{ env.DOCKER_IMAGE }}:latest,${{ env.DOCKER_IMAGE }}:${{ inputs.version }}
