24/71
Sign inSign up free

600. Build Once, Then Deploy the Artifact

medium 20 XP ~10 minHands-on lab

In /home/student/repos/docs-site, .github/workflows/ship.yml has a build job and a deploy job. It's slow and risky:

  • every run downloads all npm packages again,
  • deploy runs npm ci and npm run build a second time, so what it ships isn't the output that was tested.

Task

Change ship.yml so that:

  • build caches npm downloads between runs, keyed on the lockfile. Either actions/setup-node with cache: npm, or actions/cache with a key that uses hashFiles on package-lock.json.
  • build uploads the dist directory as an artifact named dist after testing.
  • deploy only runs after build succeeds, downloads the dist artifact, and runs ./deploy.sh dist without installing or building anything.

Keep both jobs' other steps (checkout, tests, the deploy command).

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.