ci: build Docker image only on version tags

Stop publishing on main push and remove GHCR; images go to Docker Hub only.
This commit is contained in:
O96u committed 2026-08-22 18:50:33 +08:00
1 parent 0d58d38d50
commit 80d2bca4e0
4 files changed
+4 -33

No files matched your search

+2 -29
View File
@@ -2,14 +2,12 @@ name: Publish Docker image
on: on:
push: push:
branches: [main]
tags: tags:
- 'v*' - 'v*'
workflow_dispatch: workflow_dispatch:
permissions: permissions:
contents: read contents: read
packages: write
env: env:
IMAGE_NAME: pichost IMAGE_NAME: pichost
@@ -31,44 +29,19 @@ jobs:
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 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: Log in to Docker Hub - name: Log in to Docker Hub
if: env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != ''
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
username: ${{ env.DOCKERHUB_USERNAME }} username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }} password: ${{ env.DOCKERHUB_TOKEN }}
- name: Resolve image names
id: images
run: |
names="ghcr.io/${OWNER}/${IMAGE_NAME}"
if [ -n "${DOCKERHUB_USERNAME}" ]; then
names="${names}
${DOCKERHUB_USERNAME}/${IMAGE_NAME}"
fi
{
echo "list<<EOF"
echo "${names}"
echo "EOF"
} >> "$GITHUB_OUTPUT"
env:
OWNER: ${{ github.repository_owner }}
- name: Extract metadata - name: Extract metadata
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
# Same tags for ghcr.io and Docker Hub: latest + 1.0.0 (no v prefix) images: ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}
images: ${{ steps.images.outputs.list }}
tags: | tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} type=raw,value=latest
type=semver,pattern={{version}} type=semver,pattern={{version}}
- name: Build and push - name: Build and push
+1 -1
View File
@@ -63,7 +63,7 @@ cd PicHost
docker compose up -d docker compose up -d
``` ```
Default port: **6892**. Complete the setup wizard in the browser. Image: `muxui/pichost:latest` (fallback: `ghcr.io/o96u/pichost:latest`). Default port: **6892**. Complete the setup wizard in the browser. Image: `muxui/pichost:latest`.
### Local development ### Local development
+1 -1
View File
@@ -63,7 +63,7 @@ cd PicHost
docker compose up -d docker compose up -d
``` ```
默认端口 **6892**。浏览器打开后按引导创建管理员即可。镜像:`muxui/pichost:latest`(备用 `ghcr.io/o96u/pichost:latest`)。 默认端口 **6892**。浏览器打开后按引导创建管理员即可。镜像:`muxui/pichost:latest`。
### 本地开发 ### 本地开发
-2
View File
@@ -4,8 +4,6 @@ services:
# 飞牛 Docker 对 Docker Hub 的「更新镜像」支持更好 # 飞牛 Docker 对 Docker Hub 的「更新镜像」支持更好
image: muxui/pichost:latest image: muxui/pichost:latest
pull_policy: always pull_policy: always
# 备用:GitHub Container Registry
# image: ghcr.io/O96u/pichost:latest
container_name: pichost container_name: pichost
restart: unless-stopped restart: unless-stopped
ports: ports: