fix: robust AI JSON parsing with regex fallback #28
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 Cloudflare Worker (AIDEN Proxy) | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| ai-review: | |
| name: AI Review (site QA) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Python | |
| run: | | |
| sudo apt-get update -y | |
| sudo apt-get install -y python3 python3-venv python3-pip | |
| - name: Run AI review | |
| env: | |
| AI_TEST_API_KEY: ${{ secrets.AI_TEST_API_KEY }} | |
| run: | | |
| python3 tests/ai-review.py || (echo "AI review failed" && exit 1) | |
| publish-worker: | |
| name: Publish Cloudflare Worker | |
| runs-on: ubuntu-latest | |
| needs: ai-review | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Wrangler | |
| run: | | |
| npm ci --silent || true | |
| npm install -g wrangler@2.14.0 | |
| - name: Authenticate with Cloudflare (token) | |
| env: | |
| CF_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| run: | | |
| echo "Authenticating wrangler..." | |
| # Use token auth in non-interactive mode | |
| printf "%s" "$CF_API_TOKEN" > /tmp/cf_token | |
| wrangler login --api-token $(cat /tmp/cf_token) || true | |
| - name: Publish Worker | |
| env: | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} | |
| run: | | |
| # Populate account_id in wrangler.toml at runtime to avoid committing it | |
| tmpfile=$(mktemp) | |
| jq --null-input --compact-output '{"account_id": env.CLOUDFLARE_ACCOUNT_ID}' > $tmpfile | |
| # Use wrangler publish with inline env secret for the worker | |
| wrangler publish --env production --no-delegate-account || wrangler publish --release | |
| - name: Confirm | |
| run: echo "Worker published (if no errors above)." |