BM: Baca dalam Bahasa Melayu
World 7: Robots: Actions & CI/CD
Deploy to Pages and Cloudflare
You will learn: how a workflow publishes your site to GitHub Pages or Cloudflare.
The problem
Every new diary entry, you type these on your laptop. Forget once, and readers see old pages. Time to hand the job to a robot.
Watch
Deploying is just more steps, after the tests. Put a deploy workflow in order.
First step at the top. Put these in order. Use the arrows, or drag.
- Install and test
- Check out the code
- Upload it to the host
- Build the site
- A push lands on main
Try it
GitHub Pages hosts websites straight from your repo. Set its source to GitHub Actions. Then build this workflow: pack the site, then deploy it.
Tap blocks to add them. Put them in order.
Blocks
Your workflow
Tap a block above to start.
Workflow file .github/workflows/
name: Pages
What runs
Nothing to run yet.
Hint
Trigger, permissions, job, then steps. Pack before you deploy.Watch
Cloudflare hosts sites too. This course lives there! Its tool, Wrangler, uploads your site. In a workflow, it reads two secrets: CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID. Build the command.
Tap the pieces in the right order.
Watch
Cloudflare can also watch your repo by itself. It builds and deploys on every push, with no workflow file. That is called Workers Builds. Who does what? Sort them.
Drag a card into a box. Or tap the card, then tap the box.
Predict
Your deploy job has needs: test. The tests fail. What happens to deploy?
Pick one answer.
You did it!
You can now deploy a site from a workflow.
Go deeper (optional)
id-token: write lets Pages check the deploy really comes from your workflow. No stored key needed. Pages needs its source set to GitHub Actions in the repo settings. Cloudflare also has its own action, cloudflare/wrangler-action, that runs Wrangler for you.
Bahasa Melayu
Setiap kali ada catatan diari baru, anda taip ini pada laptop. Terlupa sekali, pembaca nampak halaman lama. Masa untuk serahkan kerja ini kepada robot.
Deploy hanyalah lebih banyak langkah, selepas ujian. Susun workflow deploy ini.
GitHub Pages hos laman web terus dari repo anda. Tetapkan sumbernya kepada GitHub Actions. Kemudian bina workflow ini: bungkus laman, kemudian deploy.
Cloudflare pun hos laman. Kursus ini duduk di sana! Alatnya, Wrangler, muat naik laman anda. Dalam workflow, ia baca dua rahsia: CLOUDFLARE_API_TOKEN dan CLOUDFLARE_ACCOUNT_ID. Bina arahannya.
Cloudflare juga boleh perhati repo anda sendiri. Ia bina dan deploy pada setiap push, tanpa fail workflow. Namanya Workers Builds. Siapa buat apa? Susun.
Job deploy anda ada needs: test. Ujian gagal. Apa jadi pada deploy?
Kini anda boleh deploy laman dari workflow.
You finished this before. Practice is always welcome!
Official docs: Using custom workflows with GitHub Pages · Cloudflare Workers: GitHub Actions · Cloudflare Workers Builds
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?