name: Build xsnippet-api Docker image

on:
  # Triggered manually
  workflow_dispatch:
    inputs:
      image_name:
        description: 'The name of the resulting Docker image'
        required: false
        default: 'xsnippet/xsnippet-api'
      release_arch:
        description: 'The CPU architecture to use when choosing the xsnippet-api binary'
        required: false
        default: 'x86_64'
      release_os:
        description: 'The OS to use when choosing the xsnippet-api binary'
        required: false
        default: 'linux'
      release_tag:
        description: 'The release tag to use when choosing the xsnippet-api binary'
        required: false
        default: 'latest'
      registry:
        description: 'The Docker registry to push the image to'
        required: false
        default: 'docker.io'
      registry_username:
        description: 'The Docker registry user name'
        required: false
        default: 'xsnippetci'

jobs:
  build-and-push:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

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

      - name: Log into registry ${{ env.INPUT_REGISTRY }}
        uses: docker/login-action@v1
        with:
          registry: ${{ env.INPUT_REGISTRY }}
          username: ${{ env.INPUT_REGISTRY_USERNAME }}
          password: ${{ secrets.XSNIPPET_CI_DOCKER_HUB_PASSWORD }}

      - name: Build and push Docker image
        id: build-and-push
        uses: docker/build-push-action@v2
        with:
          context: ./docker
          push: true
          tags: ${{ env.INPUT_IMAGE_NAME}}:${{ env.INPUT_RELEASE_TAG }}
          build-args: |
            RELEASE_ARCH=${{ env.INPUT_RELEASE_ARCH }}
            RELEASE_OS=${{ env.INPUT_RELEASE_OS }}
            RELEASE_TAG=${{ env.INPUT_RELEASE_TAG }}

Create a GH workflow for building and pushing Docker images
Create a GH workflow for building and pushing Docker images

This workflow can only be launched manually at the moment.
