name: build

on:
  push:
    branches:
      - 'main'

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 10

    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Log in to the Container registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and push latest docker image
        if: success() && github.ref == 'refs/heads/main'
        run: |
          docker build . -t ghcr.io/buckaroobanzay/mtt:latest
          docker push ghcr.io/buckaroobanzay/mtt:latest
