name: Deploy to VPS on: repository_dispatch: types: [deploy] workflow_dispatch: env: VPS_HOST: 45.127.35.244 VPS_USER: root jobs: deploy: runs-on: ubuntu-latest steps: - name: Setup SSH uses: webfactory/ssh-agent@v0.9.0 with: ssh-private-key: ${{ secrets.VPS_SSH_KEY }} - name: Add VPS to known_hosts run: | mkdir -p ~/.ssh ssh-keyscan -H ${{ env.VPS_HOST }} >> ~/.ssh/known_hosts - name: Pull and restart container run: | ssh ${{ env.VPS_USER }}@${{ env.VPS_HOST }} << 'DEPLOY_EOF' set -e IMAGE_TAG="${{ github.event.client_payload.image_tag }}" IMAGE="ghcr.io/mytheclipse/proxy-bun:${IMAGE_TAG}" echo "=== Logging in to GHCR ===" echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin echo "=== Pulling image: ${IMAGE} ===" docker pull "${IMAGE}" echo "=== Updating docker-compose.yml ===" cd /opt/edge-proxy sed -i "s|image:.*|image: ${IMAGE}|" docker-compose.yml echo "=== Stopping old container ===" docker compose down || true echo "=== Starting new container ===" docker compose up -d echo "=== Waiting for health check ===" sleep 5 curl -sf http://localhost:3000/health || echo "Health check failed" echo "=== Deployment complete ===" DEPLOY_EOF - name: Verify deployment run: | sleep 10 curl -sf https://proxy.asepharyana.my.id/health || echo "External health check failed"