name: Build docker images

on:
  push:
    branches: [main]

  pull_request:
    branches: [main]

jobs:
  docker-images:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2.4.0
      with:
        submodules: true

    - name: Fetch git tags
      run: |
        git fetch --prune --unshallow --tags

    - uses: actions/setup-go@v2
      with:
        go-version: ^1.17

    - uses: actions/setup-node@v2.5.0
      with:
        node-version: '10'

    - name: Export BRANCH variable
      uses: ./.github/actions/setup-branch

    - name: Install tools
      run: make install-ci

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

    - name: Build and upload all docker images
      run: bash scripts/build-upload-docker-images.sh
      env:
        DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
        QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
