name: Main CI

on:
  push:
    branches: [ main ]
    tags:
      - '*'

jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    steps:

    - name: Set up Go 1.14
      uses: actions/setup-go@v2
      with:
        go-version: 1.14
      id: go

    - name: Check out code into the Go module directory
      uses: actions/checkout@v2

    - name: Set up Docker Buildx
      id: buildx
      uses: crazy-max/ghaction-docker-buildx@v3
      with:
        buildx-version: latest
        qemu-version: latest

    - name: Build
      run: make local

    - name: Test
      run: make test

    - name: Publish container image
      run: |
        docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
        ./hack/docker-push.sh
