name: Docker Image CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches:
      - 'main'
  workflow_dispatch:

env:
  DOCKER_TAG: dev

jobs:

  build:

    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Build the docker image
        run: docker-compose -f docker-compose.yml build

      - name: Docker login
        if: |
          github.event_name == 'push'
          && github.repository == 'go-saas/kit'
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_TOKEN }}

      - name: Push docker image
        if: |
          github.event_name == 'push'
          && github.repository == 'go-saas/kit'

        run: docker-compose -f docker-compose.yml push

          
