Files
alexa-amundson-resume/.github/workflows/auto-deploy.yml
Claude 20232bfd69 feat: add real Stripe integration, e2e tests, and Pi deployment
Replace documentation-only repo with working code:

- Stripe integration: webhook handler (8 event types), billing API
  (customers, checkout, payments, subscriptions, invoices)
- Express API server with health endpoint, structured logging
- E2E tests (Playwright): health, webhook signature verification,
  billing API validation
- Unit tests: webhook event handler coverage for all event types
- Pi deployment: deploy.sh (rsync + systemd), NGINX load balancer
  across Pi cluster, Docker support
- CI/CD: test workflow, Pi deploy workflow, updated auto-deploy
  and self-healing to run real tests before deploying
- Move resume docs to docs/ to separate code from documentation

https://claude.ai/code/session_01Mf5Pg82fV6BTRS9GnpV7nr
2026-03-04 09:00:51 +00:00

118 lines
3.4 KiB
YAML

name: Auto Deploy
on:
push:
branches: [main, master]
paths:
- 'src/**'
- 'package.json'
- 'Dockerfile'
workflow_dispatch:
env:
NODE_VERSION: '20'
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- run: npm ci
- run: npm test
detect-service:
name: Detect Service Type
runs-on: ubuntu-latest
needs: test
outputs:
service_type: ${{ steps.detect.outputs.service_type }}
deploy_target: ${{ steps.detect.outputs.deploy_target }}
steps:
- uses: actions/checkout@v4
- name: Detect Service Type
id: detect
run: |
if [ -f "next.config.mjs" ] || [ -f "next.config.js" ]; then
echo "service_type=nextjs" >> $GITHUB_OUTPUT
echo "deploy_target=cloudflare" >> $GITHUB_OUTPUT
elif [ -f "Dockerfile" ]; then
echo "service_type=docker" >> $GITHUB_OUTPUT
echo "deploy_target=railway" >> $GITHUB_OUTPUT
elif [ -f "package.json" ]; then
echo "service_type=node" >> $GITHUB_OUTPUT
echo "deploy_target=railway" >> $GITHUB_OUTPUT
elif [ -f "requirements.txt" ]; then
echo "service_type=python" >> $GITHUB_OUTPUT
echo "deploy_target=railway" >> $GITHUB_OUTPUT
else
echo "service_type=static" >> $GITHUB_OUTPUT
echo "deploy_target=cloudflare" >> $GITHUB_OUTPUT
fi
deploy-cloudflare:
name: Deploy to Cloudflare Pages
needs: detect-service
if: needs.detect-service.outputs.deploy_target == 'cloudflare'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- run: npm ci
- run: npm run build
env:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ secrets.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY }}
- uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy .next --project-name=${{ github.event.repository.name }}
deploy-railway:
name: Deploy to Railway
needs: detect-service
if: needs.detect-service.outputs.deploy_target == 'railway'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Railway CLI
run: npm i -g @railway/cli
- name: Deploy to Railway
run: railway up --service ${{ github.event.repository.name }}
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
health-check:
name: Health Check
needs: [deploy-cloudflare, deploy-railway]
if: always() && (needs.deploy-cloudflare.result == 'success' || needs.deploy-railway.result == 'success')
runs-on: ubuntu-latest
steps:
- name: Wait for Deployment
run: sleep 30
- name: Check Health Endpoint
run: |
URL="${{ secrets.DEPLOY_URL }}/api/health"
echo "Checking $URL..."
RESPONSE=$(curl -sf "$URL" 2>&1) || { echo "Health check failed"; exit 1; }
echo "$RESPONSE"
echo "$RESPONSE" | grep -q '"status":"ok"' || { echo "Unexpected health response"; exit 1; }