Pick Up the Store's Site

The turkey pre-order page is merged, and every change to the store’s site now reaches main through a reviewed pull request. But unless a shopper happens to be looking over your shoulder, nobody outside your laptop has seen any of that work, because the site still only runs on your computer.

This week, the site goes live at its own address. In this lesson, you’ll pick up the starting code, either in a ZIP or in your own repository from the last course, and file the week’s work on GitHub as issues. Then you’ll check that everything runs, so you can start putting the site online in the next lesson. Begin with what the project already holds.

Look Back at the Site So Far

The store’s site has grown a lot since it was a folder of HTML files, and each course added a habit that you keep using here:

  • Git: Every change is a commit with a clear message, and .gitignore keeps files such as notes.txt out of the repository.

  • npm and Vite: npm run dev serves the five pages while you work, npm run build writes the finished site to dist/, and the Generic Curbside key lives in an ignored .env file.

  • GitHub: The project lives in your public generic-grocery repository, and you push to it with a fine-grained token.

  • Pull requests: Each change goes on its own branch and into a pull request. You format the code with Prettier, lint it with ESLint, and squash-merge the pull request once you’ve read it.

GitHub Pages can publish a static site from files that you upload in the browser. For a Vite site, that would mean building dist/ and uploading it by hand after every merge, and sooner or later someone would upload an old build.

In this course, GitHub builds and publishes the site for you whenever a pull request merges into main.

This course starts from the last course’s finished site plus one setup commit, “Plan automatic deploys”, which touches three files:

  • README.md adds that every pull request into main runs a check.

  • scripts/check.js also reports on deploying, once there’s something to deploy.

  • .github/workflows/check.yml defines that check. GitHub runs the same lint, formatting, and build checks as your computer on every pull request into main, and you’ll read it step by step soon.

Get the Starting Code

Both routes start from the same download:

The ZIP’s generic-grocery folder includes its hidden .git folder, so the history of the first four courses comes along. If you want to keep your repository from the last course, then follow the second route. Otherwise, start from the ZIP.

Start From the ZIP

Extract the ZIP, open the generic-grocery folder in VS Code, and open a terminal with Terminal → New Terminal. Then create the ignored .env file from its example:

Language: Shell
$ cp .env.example .env

In .env, replace the placeholder with the store’s publishable key, curb_pub_fake_7Rk3vNw5. Like every key in this course, it’s fake.

The ZIP carries the Git history, but not a GitHub repository, so create an empty one. Choose New repository from the + menu on GitHub, name it generic-grocery, and make it Public, because GitHub Pages is only free for public repositories. Leave the README, .gitignore, and license options off, so the repository stays empty. Then connect your project to its HTTPS address:

Language: Shell
$ git remote add origin https://github.com/generic-grocery-dev/generic-grocery.git

Use your own login in place of generic-grocery-dev. Don’t push yet, because the next lesson starts with that push.

For the push, you need a fine-grained token for this repository with Contents set to “Read and write”, as in the last course. If you already have one for an older generic-grocery, then click the token’s name in your token list, click Edit, and pick the new repository under Repository access. If you don’t have a token yet, then open Settings → Developer settings → Personal access tokens → Fine-grained tokens on GitHub and click Generate new token:

  1. Give it a name, such as generic-grocery push, and keep the default expiration.

  2. Under Repository access, choose Only select repositories, and pick generic-grocery.

  3. Click Add permissions, pick Contents, and set it to “Read and write”.

  4. Click Generate token, and copy the token from the next page, because GitHub only shows it once.

Keep Your Own Repository

On this route, you bring in only the setup commit’s three files, and they belong on top of the last course’s finished main. You commit them straight onto main, because this one setup commit only re-creates the starting point that the ZIP supplies. Every later change to the project goes on a branch and through a pull request.

You may still be on the branch of your last pull request, or your main may not have its squash merge yet. So first check that nothing is left uncommitted. Then switch to main and pull:

Language: Shell
$ git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
$ git switch main
Already on 'main'
Your branch is up to date with 'origin/main'.
$ git pull origin main
From https://github.com/generic-grocery-dev/generic-grocery
 * branch            main       -> FETCH_HEAD
Already up to date.

If git status lists changes, then finish that work before you go on: commit it on its branch, or use git restore on the changes you don’t want to keep. If you were on another branch, then git switch main says Switched to branch 'main' instead. If GitHub’s main has the last squash merge and yours doesn’t, then git pull brings it in instead of saying Already up to date.

Now extract the ZIP outside your project, such as in Downloads, because the folder has the same name. Then copy the files from a terminal in your own generic-grocery folder, adjusting ~/Downloads if needed. The workflow file goes into a folder that your project doesn’t have yet, so mkdir -p creates it first:

Language: Shell
$ cp ~/Downloads/generic-grocery/README.md .
$ cp ~/Downloads/generic-grocery/scripts/check.js scripts/
$ mkdir -p .github/workflows
$ cp ~/Downloads/generic-grocery/.github/workflows/check.yml .github/workflows/
$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   README.md
    modified:   scripts/check.js

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    .github/

no changes added to commit (use "git add" and/or "git commit -a")

Before you stage, read the changes. git diff README.md shows a new table row for check.yml and a sentence about the check. git diff scripts/check.js is long, so skim it and press Q to leave the pager. Git lists the untracked .github/ folder rather than the file inside it. git diff doesn’t show untracked files, so open check.yml in VS Code to read it.

Stage all three files by name, because git commit -am only picks up tracked files and would leave check.yml behind without a warning:

Language: Shell
$ git add README.md scripts/check.js .github/workflows/check.yml
$ git commit -m "Plan automatic deploys"
[main b6abefe] Plan automatic deploys
 3 files changed, 184 insertions(+), 7 deletions(-)
 create mode 100644 .github/workflows/check.yml

Your hash will differ, because it depends on the author and time. For now, leave the commit on your laptop instead of pushing it, because the next lesson starts with that push.

File the Week’s Issues

Issues don’t travel in a ZIP or a push, so you create them on GitHub. They work on an empty repository too. On your repository’s Issues tab, click New issue for each of the issues below. Use the bold text, without its colon, as the title, and the rest as the description:

  • Put the store’s site live: Publish the site on GitHub Pages at the repository’s own address, so that every pull request merged into main goes live without an upload by hand.

  • Add the deals for the week of December 16: Put the deals for Wednesday, December 16, through Tuesday, December 22, in src/data/deals.js.

  • Add the deals for the week of December 23: Put the deals for Christmas week, from Wednesday, December 23, through Tuesday, December 29, in src/data/deals.js.

Copy each title exactly, because the check script looks issues up by title, whatever their numbers are.

Check That Everything Works

First, install the packages. On the ZIP route, npm downloads every package in the lockfile:

Language: Shell
$ npm install

added 97 packages, and audited 98 packages in 2s

27 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

In your own repository, npm finds the packages already in place and says up to date instead. On macOS, you can leave npm’s blocked fsevents install script unapproved, because the site doesn’t need it.

Next, start the dev server:

Language: Shell
$ npm run dev
npm notice run [email protected] dev
npm notice run vite

  VITE v8.3.8  ready in 231 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose

Hold Ctrl, or Cmd on macOS, and click the Local address to open the site in VS Code’s integrated browser. The home page shows the “Open now” badge and the store’s hours. Press Ctrl+C to stop the server.

Then check that the history ends in the setup commit:

Language: Shell
$ git log --oneline -6
15eb14c (HEAD -> main) Plan automatic deploys
69ae5ef Show each pickup day's order deadline and each size's price (#12)
ddfcc39 Add a Christmas turkey pre-order page (#11)
f59f59e Show a closing-soon notice on the home page (#10)
370f72d Add ESLint and Prettier (#9)
e42b10e Plan the move to pull requests

If the log ends in (END) or :, then it opened in a pager, and you can press Q to get your prompt back. This is the ZIP’s history. The pull request numbers (#9) to (#12) at the end of the squash commits come from the ZIP’s original repository, so yours may differ. In your own repository, the hashes differ too, and origin/main sits one commit below main.

Finally, check the whole project. If an issue you’ve created is missing from the report, then wait a minute and run the check again, because GitHub’s answers can lag behind. Here’s how the report ends in a repository kept from the last course:

Language: Shell
$ npm run check
...
! main has this course's setup commit, which isn't on GitHub yet.
  Next step: git push.
...
! GitHub's main is at 69ae5ef, yours is at b6abefe.
...
! Issue #13 "Put the store's site live" is still open.
...
! Issue #14 "Add the deals for the week of December 16" is still open.
...
! Issue #15 "Add the deals for the week of December 23" is still open.
...
✔ Everything is committed.

All checks passed, with 5 thing(s) worth a look.

Every check passes. Two of the lines marked ! say that the setup commit is still waiting for its push, and the other three list this week’s issues. Your report shows your own name, login, and issue numbers.

The longest lines are wrapped here for display:

Language: Shell
$ npm run check
npm notice run [email protected] check
npm notice run node scripts/check.js
Checking the Git repository in /Users/martin/projects/generic-grocery

✔ Git is installed (git version 2.43.0).
✔ The project folder is a Git repository.
✔ Your commits are labeled Martin Breuss <[email protected]>.
✔ .gitignore keeps notes.txt out of the repository.
✔ .gitignore keeps .DS_Store out of the repository.
✔ The history has 37 commit(s).
✔ npm is version 12 or later.
✔ You're on the main branch.
✔ package.json has "type": "module".
✔ package.json has a "check" script, so npm run check runs this report.
✔ .gitignore keeps node_modules/ out of the repository.
✔ package-lock.json is tracked, so every copy installs the same package versions.
✔ .gitignore keeps .env out of the repository.
✔ .env.example is committed, with a placeholder instead of the key.
✔ No tracked file holds a Generic Curbside secret key (curb_sec_...).
✔ origin is your GitHub repository, generic-grocery-dev/generic-grocery.
✔ main pushes to and pulls from origin/main.
! main has this course's setup commit, which isn't on GitHub yet.
  Next step: git push.
✔ No file has leftover conflict markers.
✔ Thanksgiving's hours keep both changes: 8 a.m. to 1 p.m.
✔ prettier 3.10.1 is pinned to one exact version.
✔ prettier --check . finds every file formatted.
✔ npm run lint finds no problems.
✔ GitHub has your public repository generic-grocery-dev/generic-grocery.
! GitHub's main is at 69ae5ef, yours is at b6abefe.
  Next step: git push, so GitHub gets your commits. If you just
  did, wait a minute: GitHub's answer can be a minute old.
✔ Issue #1 "Add next week's deals" is closed.
✔ Issue #2 "Add the deli counter's hours to the departments page" is closed.
✔ Issue #3 "Close at 1 p.m. on Thanksgiving" is closed.
✔ Issue #4 "Open at 8 a.m. on Thanksgiving" is closed.
✔ Issue #5 "Mark bananas down to 49¢ a pound" is closed.
✔ Issue #6 "Add ESLint and Prettier" is closed.
✔ Issue #7 "Show a closing-soon notice on the home page" is closed.
✔ Issue #8 "Add a Christmas turkey pre-order page" is closed.
! Issue #13 "Put the store's site live" is still open.
  Next step: once its work is on main, close it: Closes #13 in a
  pull request's description, or close it on GitHub. If you just
  did, wait a minute: GitHub's answer can be a minute old.
! Issue #14 "Add the deals for the week of December 16" is still open.
  Next step: once its work is on main, close it: Closes #14 in a
  pull request's description, or close it on GitHub. If you just
  did, wait a minute: GitHub's answer can be a minute old.
! Issue #15 "Add the deals for the week of December 23" is still open.
  Next step: once its work is on main, close it: Closes #15 in a
  pull request's description, or close it on GitHub. If you just
  did, wait a minute: GitHub's answer can be a minute old.
✔ Everything is committed.

All checks passed, with 5 thing(s) worth a look.

On the ZIP route, your GitHub repository is still empty, so the same report has different lines in the middle, and the final count drops from five to four:

Language: Shell
...
! main isn't on GitHub yet, so it has no upstream branch.
  Next step: git push -u origin main, once.
...
✔ GitHub has your public repository generic-grocery-dev/generic-grocery, still empty.
! Issue #1 "Put the store's site live" is still open.
...
! Issue #2 "Add the deals for the week of December 16" is still open.
...
! Issue #3 "Add the deals for the week of December 23" is still open.
...
All checks passed, with 4 thing(s) worth a look.

Every check passes here too. A new repository numbers its issues from #1. The first line marked ! refers to the push you haven’t made yet, so you don’t need to fix anything.

Until main is on GitHub, it has no upstream branch there to push to and pull from. The other three lines list this week’s issues, which the check finds by title, as on the other route. git push -u origin main is exactly where the next lesson starts.

Any other line marked ✘ comes with a Next step, so follow it and run the check again. If a line puzzles you, then the button below opens a chat with the mentor and fills in a question. Paste your report after it:

The site runs on your laptop, git log lists “Plan automatic deploys” first, and the week’s three issues wait on GitHub. In the next lesson, you’ll push the setup commit to GitHub, and you’ll find out that a workflow file asks a little more of your token than the site’s code did.

Become a Member to join the conversation.