Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
fb993000
Commit
fb993000
authored
Jan 02, 2026
by
song
Browse files
ci: DockerHub 配置可选,未配置时自动跳过
parent
678b088a
Changes
2
Hide whitespace changes
Inline
Side-by-side
.github/workflows/release.yml
View file @
fb993000
...
...
@@ -93,7 +93,10 @@ jobs:
uses
:
docker/setup-buildx-action@v3
-
name
:
Login to DockerHub
if
:
${{ env.DOCKERHUB_USERNAME != '' }}
uses
:
docker/login-action@v3
env
:
DOCKERHUB_USERNAME
:
${{ secrets.DOCKERHUB_USERNAME }}
with
:
username
:
${{ secrets.DOCKERHUB_USERNAME }}
password
:
${{ secrets.DOCKERHUB_TOKEN }}
...
...
@@ -144,11 +147,14 @@ jobs:
GITHUB_REPO_OWNER
:
${{ github.repository_owner }}
GITHUB_REPO_OWNER_LOWER
:
${{ steps.lowercase.outputs.owner }}
GITHUB_REPO_NAME
:
${{ github.event.repository.name }}
DOCKERHUB_USERNAME
:
${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_USERNAME
:
${{ secrets.DOCKERHUB_USERNAME
|| 'skip'
}}
# Update DockerHub description
-
name
:
Update DockerHub description
if
:
${{ env.DOCKERHUB_USERNAME != '' }}
uses
:
peter-evans/dockerhub-description@v4
env
:
DOCKERHUB_USERNAME
:
${{ secrets.DOCKERHUB_USERNAME }}
with
:
username
:
${{ secrets.DOCKERHUB_USERNAME }}
password
:
${{ secrets.DOCKERHUB_TOKEN }}
...
...
@@ -161,6 +167,7 @@ jobs:
env
:
TELEGRAM_BOT_TOKEN
:
${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID
:
${{ secrets.TELEGRAM_CHAT_ID }}
DOCKERHUB_USERNAME
:
${{ secrets.DOCKERHUB_USERNAME }}
continue-on-error
:
true
run
:
|
# 检查必要的环境变量
...
...
@@ -172,7 +179,6 @@ jobs:
TAG_NAME=${GITHUB_REF#refs/tags/}
VERSION=${TAG_NAME#v}
REPO="${{ github.repository }}"
DOCKER_IMAGE="${{ secrets.DOCKERHUB_USERNAME }}/sub2api"
GHCR_IMAGE="ghcr.io/${REPO,,}" # ${,,} converts to lowercase
# 获取 tag message 内容
...
...
@@ -194,14 +200,20 @@ jobs:
MESSAGE+="🐳 *Docker 部署:*"$'\n'
MESSAGE+="\`\`\`bash"$'\n'
MESSAGE+="# Docker Hub"$'\n'
MESSAGE+="docker pull ${DOCKER_IMAGE}:${TAG_NAME}"$'\n'
MESSAGE+="# GitHub Container Registry"$'\n'
# 根据是否配置 DockerHub 动态生成
if [ -n "$DOCKERHUB_USERNAME" ]; then
DOCKER_IMAGE="${DOCKERHUB_USERNAME}/sub2api"
MESSAGE+="# Docker Hub"$'\n'
MESSAGE+="docker pull ${DOCKER_IMAGE}:${TAG_NAME}"$'\n'
MESSAGE+="# GitHub Container Registry"$'\n'
fi
MESSAGE+="docker pull ${GHCR_IMAGE}:${TAG_NAME}"$'\n'
MESSAGE+="\`\`\`"$'\n'$'\n'
MESSAGE+="🔗 *相关链接:*"$'\n'
MESSAGE+="• [GitHub Release](https://github.com/${REPO}/releases/tag/${TAG_NAME})"$'\n'
MESSAGE+="• [Docker Hub](https://hub.docker.com/r/${DOCKER_IMAGE})"$'\n'
if [ -n "$DOCKERHUB_USERNAME" ]; then
MESSAGE+="• [Docker Hub](https://hub.docker.com/r/${DOCKER_IMAGE})"$'\n'
fi
MESSAGE+="• [GitHub Packages](https://github.com/${REPO}/pkgs/container/sub2api)"$'\n'$'\n'
MESSAGE+="#Sub2API #Release #${TAG_NAME//./_}"
...
...
.goreleaser.yaml
View file @
fb993000
...
...
@@ -54,9 +54,11 @@ changelog:
# Docker images
dockers
:
# DockerHub images (skipped if DOCKERHUB_USERNAME is 'skip')
-
id
:
amd64
goos
:
linux
goarch
:
amd64
skip_push
:
'
{{
if
eq
.Env.DOCKERHUB_USERNAME
"skip"
}}true{{
else
}}false{{
end
}}'
image_templates
:
-
"
{{
.Env.DOCKERHUB_USERNAME
}}/sub2api:{{
.Version
}}-amd64"
dockerfile
:
Dockerfile.goreleaser
...
...
@@ -69,6 +71,7 @@ dockers:
-
id
:
arm64
goos
:
linux
goarch
:
arm64
skip_push
:
'
{{
if
eq
.Env.DOCKERHUB_USERNAME
"skip"
}}true{{
else
}}false{{
end
}}'
image_templates
:
-
"
{{
.Env.DOCKERHUB_USERNAME
}}/sub2api:{{
.Version
}}-arm64"
dockerfile
:
Dockerfile.goreleaser
...
...
@@ -107,22 +110,27 @@ dockers:
# Docker manifests for multi-arch support
docker_manifests
:
# DockerHub manifests (skipped if DOCKERHUB_USERNAME is 'skip')
-
name_template
:
"
{{
.Env.DOCKERHUB_USERNAME
}}/sub2api:{{
.Version
}}"
skip_push
:
'
{{
if
eq
.Env.DOCKERHUB_USERNAME
"skip"
}}true{{
else
}}false{{
end
}}'
image_templates
:
-
"
{{
.Env.DOCKERHUB_USERNAME
}}/sub2api:{{
.Version
}}-amd64"
-
"
{{
.Env.DOCKERHUB_USERNAME
}}/sub2api:{{
.Version
}}-arm64"
-
name_template
:
"
{{
.Env.DOCKERHUB_USERNAME
}}/sub2api:latest"
skip_push
:
'
{{
if
eq
.Env.DOCKERHUB_USERNAME
"skip"
}}true{{
else
}}false{{
end
}}'
image_templates
:
-
"
{{
.Env.DOCKERHUB_USERNAME
}}/sub2api:{{
.Version
}}-amd64"
-
"
{{
.Env.DOCKERHUB_USERNAME
}}/sub2api:{{
.Version
}}-arm64"
-
name_template
:
"
{{
.Env.DOCKERHUB_USERNAME
}}/sub2api:{{
.Major
}}.{{
.Minor
}}"
skip_push
:
'
{{
if
eq
.Env.DOCKERHUB_USERNAME
"skip"
}}true{{
else
}}false{{
end
}}'
image_templates
:
-
"
{{
.Env.DOCKERHUB_USERNAME
}}/sub2api:{{
.Version
}}-amd64"
-
"
{{
.Env.DOCKERHUB_USERNAME
}}/sub2api:{{
.Version
}}-arm64"
-
name_template
:
"
{{
.Env.DOCKERHUB_USERNAME
}}/sub2api:{{
.Major
}}"
skip_push
:
'
{{
if
eq
.Env.DOCKERHUB_USERNAME
"skip"
}}true{{
else
}}false{{
end
}}'
image_templates
:
-
"
{{
.Env.DOCKERHUB_USERNAME
}}/sub2api:{{
.Version
}}-amd64"
-
"
{{
.Env.DOCKERHUB_USERNAME
}}/sub2api:{{
.Version
}}-arm64"
...
...
@@ -169,9 +177,11 @@ release:
**Docker:**
```bash
{{ if ne .Env.DOCKERHUB_USERNAME "skip" -}}
# Docker Hub
docker pull {{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}
{{ end -}}
# GitHub Container Registry
docker pull ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}
```
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment