diff --git a/.github/workflows/publish-site.yml b/.github/workflows/publish-site.yml new file mode 100644 index 0000000..6bf5e07 --- /dev/null +++ b/.github/workflows/publish-site.yml @@ -0,0 +1,53 @@ +name: Deploy website + +on: + workflow_run: + # Esto tiene q hacer match con los nombres de los workflows de tests + workflows: ["Lint and Typecheck"] + branches: [main, release] + types: + - completed + +jobs: + publish: + # if: ${{ github.event.workflow_run.conclusion == 'success' }} + name: Publish website to Cloudflare Workers + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + env: + ENVIRONMENT: ${{ github.event.workflow_run.head_branch == 'release' && 'production' || github.event.workflow_run.head_branch == 'main' && 'staging' || 'dev' }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + steps: + - name: ⏳ Cloning repo + uses: actions/checkout@v4 + with: + show-progress: false + + - name: 📦 Download Cached Package Dependencies + uses: actions/cache@v3 + env: + cache-name: NPM + with: + path: ~/.npm + key: CACHE-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }} + + - name: ⬢ Setup Node + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: "npm" + + - name: 📥 Install dependencies + run: npm ci --prefer-offline --no-audit --legacy-peer-deps --cache ~/.npm + + - name: Build project + run: BUILD_ENV=${{ env.ENVIRONMENT }} npm run build + + - name: Deploy + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + packageManager: npm + command: deploy --env ${{ env.ENVIRONMENT }} --minify diff --git a/wrangler.toml b/wrangler.toml new file mode 100644 index 0000000..c19ce31 --- /dev/null +++ b/wrangler.toml @@ -0,0 +1,18 @@ +name = "tickets-app" +compatibility_date = "2024-10-04" +account_id = "6e3497a44104902c23f58fe79ee984b6" +# pages_build_output_dir = "./build/client" +# compatibility_flags = ["nodejs_compat_v2"] +main = "./build/worker/index.js" +assets = { directory = "./build/client" } + +[observability] +enabled = true + +[env.staging] +[env.staging.observability] +enabled = true + +[env.production] +[env.production.observability] +enabled = true