name: Deploy to Server on: push: branches: [main] workflow_dispatch: jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 cache: npm - run: npm ci - name: Force TinaCloud schema re-index run: | echo "Triggering TinaCloud schema refresh..." curl -s -X POST \ "https://content.tinajs.io/db/${TINA_PUBLIC_CLIENT_ID}/reset/main?refreshSchema=true" \ -H "X-API-KEY: ${TINA_TOKEN}" \ -H "Content-Type: application/json" \ -o /tmp/tina-reset.json cat /tmp/tina-reset.json echo "Waiting 60s for TinaCloud to re-index..." sleep 60 env: TINA_PUBLIC_CLIENT_ID: ${{ secrets.TINA_PUBLIC_CLIENT_ID }} TINA_TOKEN: ${{ secrets.TINA_TOKEN }} - run: npm run build env: TINA_PUBLIC_CLIENT_ID: ${{ secrets.TINA_PUBLIC_CLIENT_ID }} TINA_TOKEN: ${{ secrets.TINA_TOKEN }} GITHUB_REF_NAME: ${{ github.ref_name }} - name: Setup SSH run: | mkdir -p ~/.ssh printf '%s\n' "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_deploy chmod 600 ~/.ssh/id_deploy ssh-keyscan -p 1220 57.128.160.249 >> ~/.ssh/known_hosts 2>/dev/null - name: Deploy to server run: | rsync -avz --delete \ --exclude='blog/' \ -e "ssh -p 1220 -i ~/.ssh/id_deploy" \ dist/ ubuntu@57.128.160.249:/opt/00-infrastructure/Website/website/dist/ rsync -avz \ -e "ssh -p 1220 -i ~/.ssh/id_deploy" \ server/nginx.conf ubuntu@57.128.160.249:/opt/00-infrastructure/Website/website/nginx.conf ssh -p 1220 -i ~/.ssh/id_deploy ubuntu@57.128.160.249 \ "cd /opt/00-infrastructure/Website/website && docker compose restart web"