name: Ghaymah CI/CD

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Build Docker Image
        run: |
          docker build -f q1-deploy-monitor/Dockerfile -t ghaymah-sre-api:${{ github.sha }} .

      - name: Login to Ghaymah Registry
        run: |
          echo "${{ secrets.GHAYMAH_TOKEN }}" | docker login registry.ghaymah.systems \
          -u "${{ secrets.GHAYMAH_USERNAME }}" \
          --password-stdin

      - name: Push Docker Image
        run: |
          docker tag ghaymah-sre-api:${{ github.sha }} registry.ghaymah.systems/${{ secrets.GHAYMAH_USERNAME }}/ghaymah-sre-api:${{ github.sha }}
          docker push registry.ghaymah.systems/${{ secrets.GHAYMAH_USERNAME }}/ghaymah-sre-api:${{ github.sha }}

  deploy-staging:
    needs: build
    runs-on: ubuntu-latest
    environment: staging

    steps:
      - name: Deploy to Staging
        run: |
          echo "Deploying to staging..."

  deploy-production:
    needs: deploy-staging
    runs-on: ubuntu-latest
    environment:
      name: production

    steps:
      - name: Deploy to Production
        run: |
          echo "Deploying to production..."
