name: build-tools-CI
on:
  push:
    branches:
      - main
      - v1
    paths:
      - 'tools/**'
      - 'Makefile'

jobs:
  validate:
    name: Validate
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v3
        with:
          fetch-depth: 1

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          # Username used to log in to a Docker registry. If not set then no login will occur
          username: ${{ github.repository_owner }}
          # Password or personal access token used to log in to a Docker registry. If not set then no login will occur
          password: ${{ secrets.GHCR_AUTH_PAT }}
          # Server address of Docker registry. If not set then will default to Docker Hub
          registry: ghcr.io

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

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

      - name: Build and publish Tools image
        run: make publish-build-tools
