name: Deploy Dev

on:
  pull_request:
    branches:
      - dev
    types: [closed]

jobs:
  build:
    name: Build
    runs-on: [ dev ]
    steps:
      - name: login
        run: docker login -u mathwave -p ${{ secrets.DOCKERHUB_PASSWORD }}
      - name: checkout
        uses: actions/checkout@v4
        with:
          ref: dev
      - name: build
        run: docker build -t mathwave/sprint-repo:monitoring .
  push:
    name: Push
    runs-on: [ dev ]
    needs: build
    steps:
      - name: push
        run: docker push mathwave/sprint-repo:monitoring
  deploy-dev:
    name: Deploy dev
    runs-on: [prod]
    needs: push
    steps:
      - name: login
        run: docker login -u mathwave -p ${{ secrets.DOCKERHUB_PASSWORD }}
      - name: checkout
        uses: actions/checkout@v4
        with:
          ref: dev
      - name: deploy
        env:
          CLICKHOUSE_PASSWORD_DEV: ${{ secrets.CLICKHOUSE_PASSWORD_DEV }}
        run: docker stack deploy --with-registry-auth -c ./.deploy/deploy-dev.yaml infra-development
