fix: move GCF entry point to backend root to resolve module replace i… #32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Backend to OCI VM (WebSocket) | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'backend/**' | |
| - '.github/workflows/backend-deploy-oci-vm.yml' | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24' | |
| cache-dependency-path: backend/go.sum | |
| - name: Build amd64 binary | |
| working-directory: backend | |
| run: | | |
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \ | |
| go build -tags production \ | |
| -ldflags="-w -s -extldflags '-static'" \ | |
| -o rootaccess-backend \ | |
| ./cmd/api/main.go | |
| - name: Copy binary to OCI VM | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.OCI_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.OCI_SSH_PRIVATE_KEY }} | |
| source: "backend/rootaccess-backend" | |
| target: "/tmp/" | |
| strip_components: 1 | |
| - name: Atomic deploy + health check | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.OCI_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.OCI_SSH_PRIVATE_KEY }} | |
| script: | | |
| set -e | |
| sudo mv /tmp/rootaccess-backend /opt/rootaccess/rootaccess-backend.new | |
| sudo chmod +x /opt/rootaccess/rootaccess-backend.new | |
| sudo chown rootaccess:rootaccess /opt/rootaccess/rootaccess-backend.new | |
| sudo mv /opt/rootaccess/rootaccess-backend.new /opt/rootaccess/rootaccess-backend | |
| sudo systemctl restart rootaccess | |
| for i in $(seq 1 10); do | |
| curl -sf http://localhost:8080/health && exit 0 | |
| sleep 3 | |
| done | |
| echo "Health check failed" | |
| sudo journalctl -u rootaccess -n 30 --no-pager | |
| exit 1 |