fix: Single worker strategy + ChittyRegistry integration #2
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 | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: 'Environment to deploy' | |
| required: true | |
| type: choice | |
| options: | |
| - staging | |
| - production | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - '**.md' | |
| - 'docs/**' | |
| jobs: | |
| deploy-staging: | |
| name: Deploy to Staging | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'staging') | |
| environment: | |
| name: staging | |
| url: https://chittycharge-staging.chitty.cc | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: npm test -- --run | |
| - name: Type check | |
| run: npm run typecheck | |
| - name: Deploy to Cloudflare Workers (Staging) | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| command: deploy --env staging | |
| - name: Health check | |
| run: | | |
| sleep 5 | |
| response=$(curl -s -o /dev/null -w "%{http_code}" https://chittycharge-staging.chitty.cc/health) | |
| if [ $response -eq 200 ]; then | |
| echo "✅ Staging health check passed" | |
| else | |
| echo "❌ Staging health check failed (HTTP $response)" | |
| exit 1 | |
| fi | |
| deploy-production: | |
| name: Deploy to Production | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'production' | |
| environment: | |
| name: production | |
| url: https://charge.chitty.cc | |
| needs: [] # Can add staging deployment as dependency if desired | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: npm test -- --run | |
| - name: Type check | |
| run: npm run typecheck | |
| - name: Deploy to Cloudflare Workers (Production) | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| command: deploy --env production | |
| - name: Health check | |
| run: | | |
| sleep 5 | |
| response=$(curl -s -o /dev/null -w "%{http_code}" https://charge.chitty.cc/health) | |
| if [ $response -eq 200 ]; then | |
| echo "✅ Production health check passed" | |
| else | |
| echo "❌ Production health check failed (HTTP $response)" | |
| exit 1 | |
| fi | |
| - name: Create deployment tag | |
| run: | | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| git tag -a "v$(date +%Y%m%d-%H%M%S)" -m "Production deployment" | |
| git push origin --tags |