chore: add MIT license #10
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 to Cloudflare Workers | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: npm | |
| - run: npm ci | |
| - name: Create KV namespace if needed | |
| run: | | |
| KV_ID=$(npx wrangler kv namespace list 2>/dev/null | python3 -c " | |
| import sys, json | |
| namespaces = json.load(sys.stdin) | |
| for ns in namespaces: | |
| if 'CATALOG_KV' in ns.get('title',''): | |
| print(ns['id']) | |
| break | |
| " 2>/dev/null || true) | |
| if [ -z "$KV_ID" ]; then | |
| KV_ID=$(npx wrangler kv namespace create CATALOG_KV 2>&1 | grep 'id = ' | sed 's/.*id = "\([^"]*\)".*/\1/') | |
| echo "Created new KV namespace: $KV_ID" | |
| fi | |
| echo "KV_ID=$KV_ID" | |
| echo "KV_ID=$KV_ID" >> $GITHUB_ENV | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| - name: Update wrangler.toml with KV ID | |
| run: sed -i "s/PLACEHOLDER_KV_ID/${{ env.KV_ID }}/" wrangler.toml | |
| - name: Set CNB_NPM_TOKEN as Worker Secret | |
| run: echo "${{ secrets.CNB_NPM_TOKEN }}" | npx wrangler secret put CNB_NPM_TOKEN | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| - run: npx wrangler deploy | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| - name: Trigger catalog refresh | |
| run: | | |
| sleep 3 | |
| curl -sf -X POST \ | |
| -H "Authorization: Bearer ${{ secrets.CNB_NPM_TOKEN }}" \ | |
| "https://gameframex.upm.alianblank.uk/-/refresh" || echo "Refresh failed, cron will populate on next run" |