name: Deploy on kind using Kustmize

on:
  workflow_dispatch:
  pull_request:
  schedule:
    - cron: "0 0 * * *" # This will run the workflow every day at midnight UTC

jobs:
  deploy:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-22.04, ubuntu-24.04]
        #kind: [v0.21.0, v0.22.0, v0.23.0, v0.24.0, v0.25.0]
        kind: [v0.25.0]
    steps:
      - name: Create kind
        uses: helm/kind-action@v1
        with:
          version: ${{ matrix.kind }}
      - name: Print Kubernetes Version
        run: |
          kubectl version
      - name: Test kind
        run: |
          kubectl get no
          kubectl get pods -A -o wide
          kubectl get sc
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Send Slack Notification on Success
        if: success()
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
        run: |
          curl -X POST -H 'Content-type: application/json' --data "{
            \"text\": \"✅ Kustomize Deployment Successful! :rocket:\n*OS*: ${{ matrix.os }}\n*Kind Version*: ${{ matrix.kind }}\n*Workflow*: ${{ github.workflow }}\n*Triggered by*: ${{ github.actor }}\n*Repository*: ${{ github.repository }}\"
          }" $SLACK_WEBHOOK_URL
      - name: Send Slack Notification on Failure
        if: failure()
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
        run: |
          curl -X POST -H 'Content-type: application/json' --data "{
            \"text\": \"❌ Kustomize Deployment Failed! :x:\n*OS*: ${{ matrix.os }}\n*Kind Version*: ${{ matrix.kind }}\n*Workflow*: ${{ github.workflow }}\n*Triggered by*: ${{ github.actor }}\n*Repository*: ${{ github.repository }}\n*Run URL*: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\"
          }" $SLACK_WEBHOOK_URL