agentgate / tree / .github/workflows/deploy-worker.yml ยท raw (this view has old GitHub links rewritten for the mirror; raw is byte-exact)
name: deploy-worker
# Deploys service/ to Cloudflare Workers. Needs repo secrets CLOUDFLARE_API_TOKEN (Workers edit) and CLOUDFLARE_ACCOUNT_ID.
on:
  workflow_dispatch:
  push:
    branches: [main]
    paths: ['service/**', 'src/registry.js']
jobs:
  deploy:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    env:
      HAS_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN != '' }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 22 }
      - run: npm install --no-audit --no-fund
        working-directory: service
      - run: npm test
        working-directory: service
      - name: wrangler deploy
        if: env.HAS_TOKEN == 'true'
        working-directory: service
        run: npx wrangler deploy
        env:
          CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
      - name: no token yet
        if: env.HAS_TOKEN != 'true'
        run: echo "CLOUDFLARE_API_TOKEN secret not set; skipping deploy."
      - name: smoke test live endpoint
        if: env.HAS_TOKEN == 'true'
        run: |
          U=https://agentgate.agentgate.workers.dev
          sleep 10
          curl -sS -m 30 --retry 3 -H "x-agentgate-smoke: 1" -i "$U/health"
          echo
          curl -sS -m 30 --retry 3 -H "x-agentgate-smoke: 1" -D h.txt -o b.txt "$U/v1/check-agent?id=Mf22soLh1NuZYFgBK8iSs&network=mainnet" -w "paid route HTTP %{http_code}\n"
          python3 -c "
          import base64,json
          h={l.split(':',1)[0].lower():l.split(':',1)[1].strip() for l in open('h.txt').read().splitlines() if ':' in l}
          p=json.loads(base64.b64decode(h['payment-required']))
          a=p['accepts'][0]
          print(json.dumps({'x402Version':p['x402Version'],'accept':a,'resource':p['resource'],'bazaar_info':p['extensions']['bazaar']['info']},indent=1))
          assert a['amount']=='5000' and a['network']=='eip155:8453' and a['payTo']=='0x3c1A1E01e790Cd326495631B3b38Bd7068F08d6F'
          "
          echo
          curl -sS -m 30 --retry 3 -H "x-agentgate-smoke: 1" -o /dev/null -w "preview HTTP %{http_code}\n" "$U/v1/check-agent/preview?id=Mf22soLh1NuZYFgBK8iSs" | tee pv.txt
          grep -q "preview HTTP 200" pv.txt
          curl -sS -m 30 -H "x-agentgate-smoke: 1" -H "content-type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' "$U/mcp" | tee mcp.txt
          grep -q check_agent mcp.txt

agentgate-source: code mirror on Cloudflare Pages. All repos