[FAQ] GHCR push returns denied in GitHub Actions even with packages: write

Abierto Apto para principiantes
#550 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
1/5
Tiempo estimado
Menos de una hora
Aptitud para principiantes
86/100
Tipo de issue
Documentación
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
docker, github-actions

Línea de trabajo

Lee la entrada de preguntas frecuentes del repositorio y compara sus pasos para solucionar problemas y el ejemplo de reintento con el .github/workflows/cd.yml enlazado. Confirma que la redacción distingue entre el fallo observado en el primer push y las causas habituales relacionadas con los permisos y los nombres; termina cuando la respuesta sea clara y el ejemplo apunte al workflow que funciona.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Course

ai-dev-tools-zoomcamp

Question

Final project CI/CD: my GitHub Actions workflow gets denied when pushing a new image to GHCR, even though it has packages: write and docker login succeeds. How do I fix it?

Answer

Re-run the job, and add a retry to the push. In my project the first push of each brand-new package failed, and the same push succeeded on the re-run, with no change to the workflow.

What the log looked like. The layers upload, then the push fails:

ae51df8ce05a: Pushed
error from registry: denied
denied

I had two images, and each one failed once. The first run failed on the API image. The re-run published it and then failed on the frontend image. The third run published both. Later pushes to the same packages had no problem.

Before assuming that's your issue, check the usual causes of denied:

  1. The workflow or job has permissions: packages: write. The default token may be read-only.
  2. The image name uses your own lowercase owner: ghcr.io/<owner>/<name>.
  3. docker/login-action uses password: ${{ secrets.GITHUB_TOKEN }}, and the log shows Login Succeeded!.

If all three are fine and the package doesn't exist yet, retry so a fresh setup doesn't need a manual re-run:

for attempt in 1 2 3; do
  docker push --all-tags "$repository" && break
  [ "$attempt" = 3 ] && exit 1
  sleep 15
done

I don't know the exact cause on GitHub's side. This is what I observed, on a public repository with a user-owned package.

Working example: https://github.com/devotuoma/chamaledger/blob/main/.github/workflows/cd.yml

Checklist
  • I have searched existing FAQs and this question is not already answered
  • The answer provides accurate, helpful information
  • I have included any relevant code examples or links
Lenguaje dominante
Python
Estrellas
8
Forks
20
Merge medio
3 d 14 h
PR fusionados (30 d)
3

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de DataTalksClub/faq

Todos los issues de DataTalksClub/faq

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.