Sign inSign up free

803. One Test Workflow Called by Two

hard 40 XP ~12 minHands-on lab

In /home/student/repos/storefront, .github/workflows/pr.yml and .github/workflows/nightly.yml contain the same 12-line test job, differing only in the Node version (20 for PRs, 22 nightly). Every change must be made twice.

Task

  • Create .github/workflows/test.yml, a reusable workflow (triggered by workflow_call) with:
    • a required string input node-version,
    • a required secret NPM_TOKEN,
    • one job test with the steps of today's test job, using the input for actions/setup-node and the secret as the NODE_AUTH_TOKEN environment variable of the npm ci step.
  • Replace the job in pr.yml and in nightly.yml with a job test that calls ./.github/workflows/test.yml, passing node-version ('20' and '22') and the secret NPM_TOKEN from the caller's own secrets.NPM_TOKEN.

Keep the triggers of pr.yml and nightly.yml as they are.

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.

Part of CI/CD Pipelines in Practice. Next step: Secrets in Pipelines

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.