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

オープン 初心者向け
#550 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
86/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
docker, github-actions

調査の方向性

リポジトリのFAQ項目を読み、トラブルシューティングの手順と再試行の例を、リンク先の .github/workflows/cd.yml と比較してください。記述が、観測された最初のpushの失敗と、通常の権限や命名に関する原因を区別していることを確認してください。回答が明確で、例が動作するworkflowを示していれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Python
スター
8
フォーク
20
平均マージ
3日 14時間
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

DataTalksClub/faq のほかの issue

DataTalksClub/faq の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。