Pin dependencies, lock tool versions, avoid timestamps in artifacts, and cache the deterministic parts.
A build you can trust
Pin every dependency
package-lock.json,composer.lock,go.sum,Gemfile.lock. A dependency onlatestis a dependency on tomorrow's bug.Pin tool versions
Node 20.10.0, PHP 8.2.15, Go 1.21.5. Not "the latest LTS". The latest LTS changes; your build should not.
Avoid timestamps in output
A build timestamp in the artifact makes two builds differ even when the source is identical. For build info, use git commit hash.
Cache the deterministic parts
Dependencies change less often than source. Cache
node_modulesorvendorbetween builds to cut build time by 80%.