CaptainNemo
CaptainNemo
Explore posts from servers
CDCloudflare Developers
Created by CaptainNemo on 8/17/2024 in #pages-help
Map subdomain of main site's domain to branch deployment
It's working now! Looks like I just needed to wait for the CNAME's TTL to elapse so the record would be updated. 😅 I'll leave this message up in case anyone else runs into this.
2 replies
CDCloudflare Developers
Created by stibbs on 5/1/2024 in #pages-help
How do I work with local D1 in a SvelteKit project?
Nice! Glad to hear it.
8 replies
CDCloudflare Developers
Created by stibbs on 5/1/2024 in #pages-help
How do I work with local D1 in a SvelteKit project?
@stibbs did you get it to work?
8 replies
CDCloudflare Developers
Created by stibbs on 5/1/2024 in #pages-help
How do I work with local D1 in a SvelteKit project?
I bootstrapped my project using this command: npm create cloudflare@latest my-project-name -- --framework=svelte . I followed the instructions here to get my project set up and running without D1: https://developers.cloudflare.com/pages/framework-guides/deploy-a-svelte-site/ Then I added D1 by following steps 3 through 7 on this page, except for step 6 I used npm run dev, which runs vite dev: https://developers.cloudflare.com/d1/get-started/#3-create-a-database
8 replies
CDCloudflare Developers
Created by stibbs on 5/1/2024 in #pages-help
How do I work with local D1 in a SvelteKit project?
I also have a D1 + SvelteKit project set up, and for me it runs a local D1 binding when I use vite dev. I also have the binding set in the wrangler TOML like you do. From what I understand, SvelteKit's dev server takes care of finding the binding there.
8 replies
CDCloudflare Developers
Created by CaptainNemo on 4/17/2024 in #pages-help
Deploying Pages with D1 Binding via Wrangler.toml and GH Action
And here's the whole pipeline where it's used, in case this is helpful to anyone who finds this in the future:
name: Build Log Thing
on:
push:
branches:
- main
workflow_dispatch:
pull_request:
types:
- opened
- synchronize
jobs:
build:
runs-on: ubuntu-latest
permissions:
pull-requests: write

steps:
- name: Checkout
id: checkout_repo
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}

- name: Extract vars
id: extract_vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "datetime=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT
branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
branch_trunc=${branch:0:28}
echo "branch=${branch}" >> $GITHUB_OUTPUT
echo "branch_trunc=${branch_trunc}" >> $GITHUB_OUTPUT

- name: Build
id: build_site
run: |
npm install
npm run build

- name: Deploy
id: deploy
run: npx wrangler pages deploy --branch=${{ steps.extract_vars.outputs.branch }}
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

- name: Preview URL comment
if: github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: deploy_preview
mode: recreate
message: |
## Deployed to Cloudflare Pages! :rocket:

| Name | Result |
| ----------------------- | - |
| **Preview URL**: | https://${{ steps.extract_vars.outputs.branch }}.log-thing.pages.dev |
| **Last commit:** | `${{ steps.extract_vars.outputs.sha_short }}` |
| **Deployed at**: | `${{ steps.extract_vars.outputs.datetime }}` |
name: Build Log Thing
on:
push:
branches:
- main
workflow_dispatch:
pull_request:
types:
- opened
- synchronize
jobs:
build:
runs-on: ubuntu-latest
permissions:
pull-requests: write

steps:
- name: Checkout
id: checkout_repo
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}

- name: Extract vars
id: extract_vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "datetime=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT
branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
branch_trunc=${branch:0:28}
echo "branch=${branch}" >> $GITHUB_OUTPUT
echo "branch_trunc=${branch_trunc}" >> $GITHUB_OUTPUT

- name: Build
id: build_site
run: |
npm install
npm run build

- name: Deploy
id: deploy
run: npx wrangler pages deploy --branch=${{ steps.extract_vars.outputs.branch }}
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

- name: Preview URL comment
if: github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: deploy_preview
mode: recreate
message: |
## Deployed to Cloudflare Pages! :rocket:

| Name | Result |
| ----------------------- | - |
| **Preview URL**: | https://${{ steps.extract_vars.outputs.branch }}.log-thing.pages.dev |
| **Last commit:** | `${{ steps.extract_vars.outputs.sha_short }}` |
| **Deployed at**: | `${{ steps.extract_vars.outputs.datetime }}` |
10 replies
CDCloudflare Developers
Created by CaptainNemo on 4/17/2024 in #pages-help
Deploying Pages with D1 Binding via Wrangler.toml and GH Action
For completeness, here's how I used wrangler pages deploy instead of the wrangler action:
- name: Deploy to Cloudflare Pages
id: deploy
run: npx wrangler pages deploy --branch=${{ steps.extract_vars.outputs.branch }}
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Deploy to Cloudflare Pages
id: deploy
run: npx wrangler pages deploy --branch=${{ steps.extract_vars.outputs.branch }}
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
10 replies
CDCloudflare Developers
Created by CaptainNemo on 4/17/2024 in #pages-help
Deploying Pages with D1 Binding via Wrangler.toml and GH Action
Got it working! 🚀 Thank you so much for your help!
10 replies
CDCloudflare Developers
Created by CaptainNemo on 4/17/2024 in #pages-help
Deploying Pages with D1 Binding via Wrangler.toml and GH Action
Thanks! I'll try that. You put those as environment variables in in env:? FWIW wrangler pages deploy has been picking up the TOML for me. (That's what I've been using in lieu of a GH Action---just deploying manually.)
10 replies
CDCloudflare Developers
Created by CaptainNemo on 4/17/2024 in #pages-help
Deploying Pages with D1 Binding via Wrangler.toml and GH Action
Ok I've wondered if I should just do that. How did you authenticate with Cloudflare from within your GH Action? I was under the impression that that was what the supplied action took care of (since it takes an API key). Thanks for your help!
10 replies
CDCloudflare Developers
Created by Cory on 4/12/2024 in #pages-help
How to enable unsafe binding in config
I'm also getting this error; trying to use a ratelimit binding.
5 replies
CDCloudflare Developers
Created by CaptainNemo on 4/17/2024 in #pages-help
Deploying Pages with D1 Binding via Wrangler.toml and GH Action
Interesting: it works when I do npx wrangler pages deploy manually. I don't even need to specify the output dir. Presumably it's reading that from the wrangler.toml? But why does that same command not work on GH Actions? Any help on that would be great 🤔
10 replies
CCConvex Community
Created by CaptainNemo on 8/2/2023 in #support-community
Convex dev errors because of MDX types in Astro
That worked!! Thank you so much for your help!
7 replies