fix: 🐛 update README and Docker setup documentation for GitHub Container Registry support

This commit is contained in:
isboyjc
2026-03-29 04:20:43 +08:00
parent 73cb8e8840
commit 9a4f08a5e7
3 changed files with 77 additions and 27 deletions

View File

@@ -30,13 +30,24 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata
id: meta
- name: Extract metadata for GHCR
id: meta-ghcr
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY_DOCKERHUB }}/${{ env.IMAGE_NAME }}
${{ env.REGISTRY_GHCR }}/${{ env.IMAGE_NAME }}
images: ${{ env.REGISTRY_GHCR }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Extract metadata for Docker Hub
id: meta-dockerhub
if: secrets.DOCKERHUB_USERNAME != ''
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_DOCKERHUB }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
@@ -45,7 +56,7 @@ jobs:
type=raw,value=latest,enable={{is_default_branch}}
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
if: github.event_name != 'pull_request' && secrets.DOCKERHUB_USERNAME != ''
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_DOCKERHUB }}
@@ -60,13 +71,24 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
- name: Build and push to GHCR
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta-ghcr.outputs.tags }}
labels: ${{ steps.meta-ghcr.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push to Docker Hub
if: github.event_name != 'pull_request' && secrets.DOCKERHUB_USERNAME != ''
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta-dockerhub.outputs.tags }}
labels: ${{ steps.meta-dockerhub.outputs.labels }}
cache-from: type=gha