name: Build and Deploy

on:
  push:
    branches:
      - main

jobs:
  docker:
    runs-on: POC-Master0

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
    
      - name: Login to Harbor
        uses: docker/login-action@v3
        with:
          registry: ${{ vars.REGISTRY }}
          username: ${{ secrets.HARBOR_USERNAME }}
          password: ${{ secrets.HARBOR_PASSWORD }}

      - name: Build container
        run: /root/work/pipeline/build_container.sh ${{ github.event.repository.name }} ${{ vars.REGISTRY }}

      - name: Create kubeconfig
        run: |
          echo "${{ secrets.KUBECONFIG_DEV }}"  > ./kubeconfig
          chmod 600 ./kubeconfig
        
      - name: variables sustitution
        run: /root/work/pipeline/customize.sh dev 

      - name: k8s deploy
        run: /root/work/pipeline/deploy.sh
   
