name: Docker Release Image

on:
  push:
    # Pattern matched against refs/tags
    tags:
      - '**'           # Push events to every tag including hierarchical tags like v1.0/beta

env:
  DOCKER_TAG: ${{github.ref_name}}

jobs:

  build:

    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Build the docker image
        run: docker-compose -f docker-compose.yml -f docker-compose.ms.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 -f docker-compose.ms.yml push
