Skip to content

fix: use GITHUB_TOKEN instead of GHA_CR_TOKEN for GHCR authentication#53

Merged
mithro merged 2 commits intomainfrom
fix/use-github-token-for-ghcr
Dec 12, 2025
Merged

fix: use GITHUB_TOKEN instead of GHA_CR_TOKEN for GHCR authentication#53
mithro merged 2 commits intomainfrom
fix/use-github-token-for-ghcr

Conversation

@mithro
Copy link
Owner

@mithro mithro commented Dec 12, 2025

Summary

  • Replace custom GHA_CR_TOKEN PAT with built-in GITHUB_TOKEN
  • Add permissions block with packages: write
  • Simplify push logic (no need to check for token existence)
  • Update docker/login-action from v1 to v3
  • Fix deprecated ::set-output command

Background

The "Publish Docker image" workflow was failing on all push events because GHA_CR_TOKEN was invalid/expired. Pull requests succeeded only because they skip the ghcr.io push entirely.

See issue #52 for the full investigation.

Changes

Before After
Custom PAT (GHA_CR_TOKEN) Built-in GITHUB_TOKEN
Manual token management Automatic rotation
Check if token exists Always available
::set-output (deprecated) GITHUB_OUTPUT env file
docker/login-action@v1 docker/login-action@v3

Test plan

  • Verify PR checks pass (pull_request event - pushes to localhost only)
  • After merge, verify push event successfully publishes to ghcr.io

Fixes #52

🤖 Generated with Claude Code

mithro and others added 2 commits December 12, 2025 14:08
Prevent worktree contents from being tracked in the repository.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The custom GHA_CR_TOKEN PAT was invalid/expired, causing all push events
to fail when publishing Docker images to ghcr.io.

Changes:
- Add permissions block with `packages: write` for GITHUB_TOKEN
- Replace GHA_CR_TOKEN with GITHUB_TOKEN (always available)
- Simplify push logic (no need to check for token existence)
- Update docker/login-action from v1 to v3
- Replace deprecated `::set-output` with GITHUB_OUTPUT env file

Benefits:
- No manual token management required
- Token is automatically rotated by GitHub
- Proper permissions scoped per-workflow

Fixes #52

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings December 12, 2025 04:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes authentication failures in the Docker image publishing workflow by replacing the custom GHA_CR_TOKEN personal access token with the built-in GITHUB_TOKEN, which is automatically provided and managed by GitHub Actions.

Key Changes:

  • Replaced custom PAT authentication with GITHUB_TOKEN and added required packages: write permission
  • Updated from deprecated ::set-output command to the GITHUB_OUTPUT environment file approach
  • Upgraded docker/login-action from v1 to v3

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
.gitignore Added .worktrees/ entry for Git worktree support
.github/workflows/publish-docker-image.yml Fixed GHCR authentication by switching to GITHUB_TOKEN, added permissions block, updated to non-deprecated output mechanism, and upgraded login action version

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

print("Skipping GitHub Container Repository (ghcr.io)")
print("Skipping GitHub Container Repository (ghcr.io) for non-push events")

l = ",".join(i)
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name l (lowercase L) is ambiguous and easily confused with the number 1 or uppercase I. Consider renaming it to something more descriptive like locations or images_list.

Copilot uses AI. Check for mistakes.
@mithro mithro merged commit ed0bef2 into main Dec 12, 2025
10 of 19 checks passed
@mithro mithro deleted the fix/use-github-token-for-ghcr branch December 12, 2025 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Publish Docker image workflow fails on push events due to invalid GHA_CR_TOKEN

2 participants