diff --git a/.github/workflows/pages.yml b/.github/workflows/deploy.yml similarity index 50% rename from .github/workflows/pages.yml rename to .github/workflows/deploy.yml index 41f2fda..a393501 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/deploy.yml @@ -7,15 +7,13 @@ on: permissions: contents: read - pages: write - id-token: write concurrency: - group: pages + group: deploy cancel-in-progress: false jobs: - build: + deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -27,15 +25,13 @@ jobs: - run: pnpm install --frozen-lockfile - run: pnpm test - run: pnpm app:build - - uses: actions/upload-pages-artifact@v3 + # Needs repository secrets CLOUDFLARE_API_TOKEN (Workers Scripts: Edit) and + # CLOUDFLARE_ACCOUNT_ID; without them the build still runs but nothing is deployed. + - name: Deploy to Cloudflare Workers + env: + HAS_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN != '' }} + if: env.HAS_TOKEN == 'true' + uses: cloudflare/wrangler-action@v3 with: - path: app-dist - deploy: - needs: build - runs-on: ubuntu-latest - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - steps: - - id: deployment - uses: actions/deploy-pages@v4 + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} diff --git a/.gitignore b/.gitignore index 3dc2c8d..1fef293 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules/ dist/ app-dist/ *.tgz +.wrangler/ diff --git a/README.md b/README.md index 3987ead..07fa272 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ pnpm test # núcleo con pruebas / tested core (vitest) pnpm build # dist/ pnpm enzymes # regenerar el catálogo desde REBASE / rebuild the catalogue from REBASE pnpm app:dev # app independiente / standalone app (vector-editor.oquinterol.com) +pnpm app:deploy # Cloudflare Worker (wrangler): vector-editor.oquinterol.com ``` ## Se apoya en / Builds on diff --git a/app/public/CNAME b/app/public/CNAME deleted file mode 100644 index 8ab802a..0000000 --- a/app/public/CNAME +++ /dev/null @@ -1 +0,0 @@ -vector-editor.oquinterol.com diff --git a/app/public/_headers b/app/public/_headers new file mode 100644 index 0000000..a41a93b --- /dev/null +++ b/app/public/_headers @@ -0,0 +1,8 @@ +/* + X-Content-Type-Options: nosniff + Referrer-Policy: strict-origin-when-cross-origin + Permissions-Policy: camera=(), microphone=(), geolocation=() + X-Frame-Options: SAMEORIGIN + +/assets/* + Cache-Control: public, max-age=31536000, immutable diff --git a/package.json b/package.json index cbaa8a2..8c6d476 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,8 @@ "typecheck": "tsc --noEmit", "enzymes": "node scripts/build-enzymes.mjs", "app:dev": "vite", - "app:build": "vite build" + "app:build": "vite build", + "app:deploy": "pnpm app:build && wrangler deploy" }, "peerDependencies": { "react": "^18.0.0 || ^19.0.0", diff --git a/wrangler.jsonc b/wrangler.jsonc new file mode 100644 index 0000000..b2716fa --- /dev/null +++ b/wrangler.jsonc @@ -0,0 +1,14 @@ +{ + // Static app served by a Cloudflare Worker at vector-editor.oquinterol.com. + "$schema": "node_modules/wrangler/config-schema.json", + "name": "vector-editor", + // Oaql97@gmail.com account (owner of the oquinterol.com zone). + "account_id": "1334cd1c58712e97ee632f6507e4c659", + "compatibility_date": "2026-10-01", + "assets": { + "directory": "./app-dist", + "not_found_handling": "single-page-application" + }, + "routes": [{ "pattern": "vector-editor.oquinterol.com", "custom_domain": true }], + "observability": { "enabled": true } +}