Repository navigation
[codex] Add edge push deploy workflow #2
Workflow file for this run
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: CI | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up Node | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm run install:all | |
| - name: Build static assets | |
| run: npm run build | |
| - name: Build backend release | |
| run: | | |
| rm -rf release | |
| mkdir -p release | |
| cp package.json package-lock.json release/ | |
| cp -R server release/server | |
| (cd release/server && npm ci --omit=dev) | |
| - name: Smoke test backend release | |
| run: | | |
| cd release | |
| PORT=31081 \ | |
| NODE_ENV=production \ | |
| POSTGRES_HOST=127.0.0.1 \ | |
| POSTGRES_PORT=5432 \ | |
| POSTGRES_USER=catalyst_user \ | |
| POSTGRES_PASSWORD=test \ | |
| POSTGRES_DATABASE=catalyst_pro \ | |
| JWT_SECRET=test \ | |
| JWT_EXPIRES_IN=7d \ | |
| GEMINI_API_KEY=test \ | |
| npm run start & | |
| pid="$!" | |
| trap 'kill "$pid" 2>/dev/null || true' EXIT | |
| for _ in $(seq 1 20); do | |
| curl -fsS http://127.0.0.1:31081/api/health >/dev/null && exit 0 | |
| sleep 1 | |
| done | |
| exit 1 | |
| deploy-edge: | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| needs: validate | |
| runs-on: ubuntu-latest | |
| environment: production | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up Node | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm run install:all | |
| - name: Build static assets | |
| run: npm run build | |
| - name: Build backend release | |
| run: | | |
| rm -rf release | |
| mkdir -p release | |
| cp package.json package-lock.json release/ | |
| cp -R server release/server | |
| (cd release/server && npm ci --omit=dev) | |
| - name: Upload static assets to edge | |
| uses: shipstuff/actions/digital-ocean-upload@main | |
| with: | |
| ssh-private-key: ${{ secrets.EDGE_KEY }} | |
| edge-user: catalystpro | |
| source-path: client/dist | |
| delete: "true" | |
| - name: Create backend deploy marker | |
| run: | | |
| mkdir -p .deploy-marker | |
| printf '{"release":"%s"}\n' "${GITHUB_SHA}" > ".deploy-marker/${GITHUB_SHA}.json" | |
| - name: Upload backend release to edge | |
| uses: shipstuff/actions/digital-ocean-upload@main | |
| with: | |
| ssh-private-key: ${{ secrets.EDGE_KEY }} | |
| edge-user: catalystpro | |
| source-path: release | |
| edge-path: /home/catalystpro/releases/${{ github.sha }}/ | |
| delete: "true" | |
| - name: Queue backend activation | |
| uses: shipstuff/actions/digital-ocean-upload@main | |
| with: | |
| ssh-private-key: ${{ secrets.EDGE_KEY }} | |
| edge-user: catalystpro | |
| source-path: .deploy-marker | |
| edge-path: /home/catalystpro/deploy-queue/ | |
| delete: "false" | |
| wait-for-marker: "true" | |
| marker-name: ${{ github.sha }}.json |