`buildx failed with: ERROR: failed to solve: failed to push 111122223333.dkr.ecr.ap-south-1.amazonaws.com/shack-api:sha-a1b2c3d: unexpected status from HEAD request ... 401 Unauthorized`
IntermediateTroubleshootingCaching, Artifacts, Builds & Scans
Answer
Likely causes → No docker login to ECR (missing aws-actions/amazon-ecr-login), login done before credentials were configured, region mismatch, or login token expired in a very long job.
Diagnose → Check step order: configure-aws-credentials, then amazon-ecr-login, then build.
Fix →
- uses: aws-actions/configure-aws-credentials@v4
with: { role-to-assume: "${{ vars.ECR_PUSH_ROLE_ARN }}", aws-region: ap-south-1 }
- id: ecr
uses: aws-actions/amazon-ecr-login@v2
Prevent → Keep auth steps immediately before the push.
More on Caching, Artifacts, Builds & Scans
`Cache not found for input keys: npm-Linux-3f9a...` on every single run.Beginner`Failed to save: Unable to reserve cache with key npm-Linux-3f9a..., another job may be creating this cache.`BeginnerA cache restores but the build is still slow and reinstalls everything.Intermediate`Error: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run`Beginner`Error: Unable to download artifact(s): Artifact not found for name: build`Beginner`Warning: No files were found with the provided path: coverage/. No artifacts will be uploaded.` but tests ran.Beginner