Lab GuideDeploy your Worker
14:30 17:00

LAB GUIDE / SECTION 02

Deploy your Worker

2.1 One click → repo + live Worker#

Your Worker starts from the class template repo: https://github.com/RoderickOxen/iscte-workers-template. You don't clone that one or change it. The button below makes your own copy of it.

Click: Deploy to Cloudflare

On the deploy page:

  1. Connect GitHub when asked, and allow access to your account.
  2. Project name (and repo name, if asked separately): type <your-droid-name>, your Droid Name.
  3. Click Deploy and wait about a minute.

That's all it asks for: names, and nothing secret. There are no API keys in this class.

In that one click, Cloudflare:

  • copied the template into a new repo on your GitHub: github.com/<your-github-user>/<your-droid-name>. It's yours: not a fork, no link back to the template,
  • built and deployed it to your Cloudflare account,
  • set up Workers Builds: from now on, every git push to your repo redeploys your Worker automatically.
Template repo (the teacher's)Your repo
URLgithub.com/RoderickOxen/iscte-workers-templategithub.com/<your-github-user>/<your-droid-name>
You…used it once, through the buttonclone it, edit it, push to it
Deploysnothingyour Worker, on every push

Open the URL it shows you. It should be https://<your-droid-name>.<your-subdomain>.workers.dev. You're on the internet.

Tip

Different URL from the one above (another name, a changed subdomain)? Fix it in Your project at the top of the page, so every command later in the guide is right.

2.2 Get the code on your laptop#

Clone your repo, the copy the button just made, not the template:

sh
git clone https://github.com/<your-github-user>/<your-droid-name>.git
cd <your-droid-name>
npm install

2.3 Run it locally#

sh
npm run dev          # same as: npx wrangler dev

Open http://localhost:8787. It's the same page, running on your laptop in the same runtime Cloudflare uses (workerd). Edit, save, refresh: changes appear instantly.

You'll see a Droid ID card with every row saying "unknown", and a hint box: "Character: unknown. Finish Mission 2 to load your character." That's expected. You'll fill the card in during Mission 2.

Two things to notice:

  • Your Pixel Droid (the little robot next to your name) looks different on localhost. It's drawn from your Worker's URL, and localhost is a different URL. Once you deploy, it matches the one the Hub shows in the Directory.
  • The button at the top right switches between light, dark and system themes.

Note

Wrangler may ask you to log in again, or which account to use. Your Worker has an AI binding, and Wrangler connects to Cloudflare for it even in local dev. Pick the account you created today. Stuck? See Troubleshooting.

Check#

  • https://<your-droid-name>.<your-subdomain>.workers.dev loads (placeholder name, an empty ID card with a hint)
  • The footer says Served from a three-letter code: the Cloudflare data centre nearest you (probably LIS). Check this on your live URL: locally it shows something else, because your laptop is the data centre. Open it through a VPN in another country and the code changes, even though you only deployed once
Something failed?
  • Deploy page asks you to create a workers.dev subdomain: you skipped step 1.1.4. Pick a short name, then update Cloudflare subdomain under Your project at the top of this page, so your URLs here are right.
  • npm run dev asks which account, or fails with an account error: you have several Cloudflare accounts. See Troubleshooting.
  • Build failed: in the Cloudflare dashboard go to Workers & Pages → your Worker → Deployments → View build and read the log. Most often it's an unverified email.
  • npm run dev port in use: npx wrangler dev --port 8788.

Next: Make it yours

Checks are saved automatically on this browser.

Your project

Pick your Droid Name first. Add the rest when you know it; every field is optional. These details stay in this browser and are never sent anywhere.

A nickname, not your full name. Used for your Student Worker and repo. Lowercase letters, numbers and hyphens; up to 40 characters.

The workers.dev subdomain you choose at signup. Same naming rules as your Droid Name.

Add this later, or paste a GitHub repo URL to fill your username and Droid Name.

My URL is different

Optional. Use your public https://…workers.dev URL. Paths and trailing slashes are removed. Leave blank to use your Droid Name and subdomain.

LIVE PREVIEW

Your droid will live at https://<your-droid-name>.<your-subdomain>.workers.dev

Your repo: github.com/<your-github-user>/<your-droid-name>