Interview Prep/GitHub Actions/Caching, Artifacts, Builds & Scans

`tag invalid: The image tag 'sha-a1b2c3d' already exists in the 'shack-api' repository and cannot be overwritten because the repository is immutable.`

IntermediateTroubleshootingCaching, Artifacts, Builds & Scans
Answer

Likely causes → A re-run or a second workflow pushes the same commit tag again; ECR tag immutability is on (good).

Diagnose →

aws ecr describe-images --repository-name shack-api --image-ids imageTag=sha-a1b2c3d

Fix → Make the push idempotent: skip build and push if the tag exists and output the existing digest; never push mutable tags like latest to an immutable repo.

Prevent → Check-then-push step at the start of the build job.

All GitHub Actions questions Roadmap: GitHub Actions

More on Caching, Artifacts, Builds & Scans