Deploy
GitHub to Cloudflare
หน้าเว็บใช้ Cloudflare Pages auto deploy จาก GitHub ส่วน backend ใช้ GitHub Actions เรียก wrangler deploy ทุกครั้งที่ push เข้า mainThe frontend uses Cloudflare Pages auto-deploy from GitHub, while the backend uses GitHub Actions to run wrangler deploy on every push to main.
- Push repo นี้ขึ้น GitHubPush this repository to GitHub.
- Connect GitHub repo กับ Cloudflare Pages โดยตั้ง root เป็น webConnect the repo to Cloudflare Pages and set the root directory to web.
- ผูก custom domain ของ Pages เป็น rinbooks.comAttach the custom domain rinbooks.com to the Pages project.
- ตั้ง build command เป็น npm run build และ output directory เป็น outSet the build command to npm run build and the output directory to out.
- เตรียม Postgres และสร้าง R2 bucketPrepare Postgres and create an R2 bucket.
- เพิ่ม Cloudflare Worker secrets สำหรับ connection string ทั้ง read และ writeAdd Cloudflare Worker secrets for read and write connection strings.
- ให้ DNS ของ rinbooks.com ชี้เข้า Cloudflare PagesPoint rinbooks.com DNS to Cloudflare Pages.
- เพิ่ม GitHub secrets: CLOUDFLARE_API_TOKEN และ CLOUDFLARE_ACCOUNT_IDAdd the GitHub secrets CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID.
- Push เข้า branch main เพื่อให้ GitHub Action deploy Worker อัตโนมัติPush to main so GitHub Actions can deploy the Worker automatically.