A workflow rebuilds the same image in staging and prod deploys. What is wrong and how do you fix it?
IntermediateScenarioSpeed, Caching & Cost
Answer
Situation read → Rebuilding per environment wastes minutes and breaks the guarantee that tested equals shipped.
What I'd do →
- Build once in a
buildjob, output the digest. - Deploy jobs (or reusable workflow calls) use
image@digestfromneeds.build.outputs.digest. - Promotion to prod via release tag adds a tag to the existing manifest, no rebuild.
Why → Rebuilds can pull different base images or dependencies, so prod runs something nobody tested.
Interview tip → "Build once, deploy many, by digest."
More on Speed, Caching & Cost
`npm ci` takes 4 minutes on every run. Fix it.BeginnerDocker builds take 12 minutes even when only one line of code changed. Speed them up.IntermediateThe repo hits the 10 GB cache limit daily and hit rates are poor. What do you change?IntermediatemacOS jobs are 60% of your bill. What are your options?IntermediateA job sometimes hangs and burns 6 hours. How do you stop it happening again?BeginnerYour PR matrix is 3 OS times 4 versions (12 jobs). How do you cut cost without losing coverage?Advanced