name: Deploy powerbar.ti Frontend Portal
run-name: ${{ gitea.actor }} is deploying the frontend.
on:
  push:
    branches:
      - main
jobs:
  Deploy-Tinance2-Frontend-Portal-Production:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
        uses: actions/checkout@v3

      - name: Configure SSH
        run: |
          mkdir -p ~/.ssh/
          echo "${{ secrets.SSH_KEY }}" | tr -d '\r' > ~/.ssh/id_rsa
          chmod 600 ~/.ssh/id_rsa
          cat >>~/.ssh/config <<END
          Host production
            HostName 10.209.60.143
            User root
            StrictHostKeyChecking no
          END
          cat ~/.ssh/config
        env:
          SSH_USER: ${{ secrets.SSH_USER }}
          SSH_KEY: ${{ secrets.SSH_KEY }}

      - name: Production Update Portal
        run: ssh production 'bash /root/deploy_portal_script.sh'