-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(actions): add docker-registry.yml for automatic ghcr.io image publishing #463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| name: Build and Push Docker Image | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
|
|
||
| jobs: | ||
| docker: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v3 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Log in to GitHub Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Extract metadata for Docker image | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: | | ||
| ghcr.io/${{ github.repository_owner }}/voicebox | ||
| tags: | | ||
| type=semver,pattern={{version}} | ||
| type=raw,value=latest,enable=${{ github.ref == format('"refs/heads/{0}"', github.default_branch) }} | ||
|
|
||
| - name: Build and push with metadata | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| platforms: linux/amd64,linux/arm64 | ||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
Comment on lines
+1
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Verify the Docker registry workflow is in GitHub Actions' discovery directory.
set -euo pipefail
echo "Workflow files found:"
fd -a '^docker-registry\.ya?ml$' . 2>/dev/null || true
test -f .github/workflows/docker-registry.ymlRepository: jamiepine/voicebox Length of output: 139 Move this workflow under The current path is 🔧 Proposed fix-github/workflows/docker-registry.yml
+.github/workflows/docker-registry.yml🤖 Prompt for AI Agents
Comment on lines
+42
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
fd -HI -t f '^Dockerfile' .
rg -n 'latest-(cuda|rocm)' docs/ || trueRepository: jamiepine/voicebox Length of output: 563 🏁 Script executed: cat -n .github/docker-registry.ymlRepository: jamiepine/voicebox Length of output: 1761 Update documentation or extend workflow to build CUDA/ROCm variants. The workflow only builds a single image variant tagged 🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
docker/metadata-action is_default_branch enable tag semver💡 Result:
docker/metadata-action supports the global expression {{is_default_branch}} (true when the branch that triggered the workflow run is the repository’s default branch) and lets you use it to conditionally enable tag-generation. Separately, it supports SemVer tags via the tag type type=semver with patterns like {{version}}. Example (set a “latest” tag only when the workflow is triggered from the default branch, and also generate SemVer-derived tags from Git tag refs): tags: | # generate version tags from semver Git tags type=semver,pattern={{version}} # only add “latest” when this run is from the default branch type=raw,value=latest,enable={{is_default_branch}} How it fits together: - type=semver: used for SemVer tags when the workflow is triggered by a push to a Git tag, and uses a pattern such as {{version}} (or other semver components). - {{is_default_branch}}: returns true only for runs triggered by the repo’s default branch; you can place it in enable=... to conditionally emit certain tags (commonly used for “latest”). So the phrase “docker/metadata-action is_default_branch enable tag semver” corresponds to combining: 1) enable={{is_default_branch}} to gate a tag on default-branch runs, and 2) type=semver,pattern=... to emit SemVer tags.
Citations:
latesttag will never be applied — broken condition and mismatched trigger.Two problems with this line:
push: tags: ['v*'], sogithub.refis alwaysrefs/tags/vX.Y.Z— neverrefs/heads/<default_branch>. Theenableexpression can therefore never evaluate to true on this trigger.format('"refs/heads/{0}"', github.default_branch)call wraps the result in literal double quotes, producing the string"refs/heads/main"(quotes included), which would never equalgithub.refeven on a branch push.If the intent is to tag
lateston semver releases from the default branch, usetype=raw,value=latest,enable={{is_default_branch}}(supported bydocker/metadata-action), which correctly handles tag pushes. Otherwise, drop theenable=clause to always applylateston version-tag pushes.🔧 Proposed fix
tags: | type=semver,pattern={{version}} - type=raw,value=latest,enable=${{ github.ref == format('"refs/heads/{0}"', github.default_branch) }} + type=raw,value=latest,enable={{is_default_branch}}🤖 Prompt for AI Agents