Skip to content

Commit b1163fe

Browse files
committed
ci: retarget container builds to ghcr
1 parent 3a374ec commit b1163fe

5 files changed

Lines changed: 20 additions & 14 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
file: Dockerfile.github
6363
platforms: ${{ inputs.platforms }}
6464
push: ${{ inputs.push == 'true' }}
65-
tags: ghcr.io/${{ github.repository }}/vohive:dev
65+
tags: ghcr.io/${{ github.repository }}:dev
6666
provenance: false
6767
sbom: false
6868
cache-from: type=gha

.github/workflows/docker-publish.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Push Docker Image
1+
name: Build and Push GHCR Image
22

33
on:
44
push:
@@ -12,11 +12,14 @@ on:
1212
default: "true"
1313

1414
env:
15-
DOCKER_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/vohive
15+
CONTAINER_IMAGE: ghcr.io/${{ github.repository }}
1616

1717
jobs:
1818
build:
1919
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
2023
steps:
2124
- name: Checkout repository
2225
uses: actions/checkout@v4
@@ -27,21 +30,24 @@ jobs:
2730
- name: Set up Docker Buildx
2831
uses: docker/setup-buildx-action@v3
2932

30-
- name: Login to DockerHub
33+
- name: Login to GHCR
3134
if: github.event_name != 'pull_request'
3235
uses: docker/login-action@v3
3336
with:
34-
username: ${{ secrets.DOCKERHUB_USERNAME }}
35-
password: ${{ secrets.DOCKERHUB_TOKEN }}
37+
registry: ghcr.io
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
3640

3741
- name: Extract metadata (tags, labels)
3842
id: meta
3943
uses: docker/metadata-action@v5
4044
with:
41-
images: ${{ env.DOCKER_IMAGE }}
45+
images: ${{ env.CONTAINER_IMAGE }}
4246
tags: |
4347
# 总是打上 latest 标签
4448
type=raw,value=latest,enable=true
49+
# 保留 Git tag 标签 (例如 v1.0.0)
50+
type=ref,event=tag
4551
# 语义化精确版本标签 (例如 v1.0.0 会被转换为 1.0.0)
4652
type=semver,pattern={{version}}
4753

DOCKERHUB.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ EOF
3434
```yaml
3535
services:
3636
vohive:
37-
image: iniwex/vohive:latest
37+
image: ghcr.io/boa-z/vohive:latest
3838
container_name: vohive
3939
restart: unless-stopped
4040
ports:

docker-compose.hub.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Docker Compose 配置 - 使用 DockerHub 预构建镜像
2-
# 镜像地址: iniwex/vohive
1+
# Docker Compose 配置 - 使用 GHCR 预构建镜像
2+
# 镜像地址: ghcr.io/boa-z/vohive
33
# 用法: docker-compose -f docker-compose.hub.yml up -d
44

55
services:
66
vohive:
7-
image: iniwex/vohive:latest
7+
image: ${VOHIVE_IMAGE:-ghcr.io/boa-z/vohive:latest}
88
container_name: vohive
99
restart: unless-stopped
1010
ports:

scripts/ci.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ dependency_hygiene() {
5555

5656
forbidden_refs="$(
5757
{
58-
git grep -nE 'github[.]com/iniwex5|github[.]com/boa-z/qqbot|vohive[-]release|GO[.]?PRIVATE|GO[.]?NOSUMDB|GH[_]PAT' -- \
59-
go.mod go.sum .github Dockerfile Dockerfile.github docker-compose.yml Makefile scripts internal cmd pkg web/src \
58+
git grep -nE 'github[.]com/iniwex5|github[.]com/boa-z/qqbot|iniwex[/]vohive|DOCKERHUB[_]|secrets[.]DOCKERHUB|vohive[-]release|GO[.]?PRIVATE|GO[.]?NOSUMDB|GH[_]PAT' -- \
59+
go.mod go.sum .github Dockerfile Dockerfile.github Dockerfile.runtime docker-compose.yml docker-compose.hub.yml DOCKERHUB.md Makefile scripts internal cmd pkg web/src \
6060
':!internal/web/dist/**' ':!web/dist/**' || true
6161
git grep -nE 'replace[[:space:]].*=>[[:space:]]*(\.{1,2}/|/|~)' -- \
62-
go.mod go.sum .github Dockerfile Dockerfile.github docker-compose.yml Makefile scripts internal cmd pkg web/src \
62+
go.mod go.sum .github Dockerfile Dockerfile.github Dockerfile.runtime docker-compose.yml docker-compose.hub.yml DOCKERHUB.md Makefile scripts internal cmd pkg web/src \
6363
':!internal/web/dist/**' ':!web/dist/**' || true
6464
} | sed '/^$/d'
6565
)"

0 commit comments

Comments
 (0)