name: "Setup Docker"

outputs:
  sha_short:
    description: "The short SHA used for image builds"
    value: ${{ steps.vars.outputs.sha_short }}
  tag:
    description: "The tag if run against a tag, otherwise 'canary'"
    value: ${{ steps.vars.outputs.tag }}

runs:
  using: "composite"
  steps:
    - name: Get Short SHA & Tag
      id: vars
      run: |
        echo ::set-output name=sha_short::${GITHUB_SHA::7}
        TAG=${GITHUB_REF##*/}
        if [ "main" == "${TAG}" ]; then
          TAG=canary
        fi
        echo ::set-output name=tag::${TAG:-canary}
      shell: bash

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

    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v1
      with:
        version: latest

    # - name: Login to DockerHub
    #   if: ${{ github.ref == 'main' && github.event.pull_request.merged == true }}
    #   uses: docker/login-action@v1
    #   with:
    #     username: ${{ inputs.username }}
    #     password: ${{ inputs.password }}
