fix: switch chat-deploy auto build to Docker Hub
All checks were successful
itom-platform auto build image / build (push) Successful in 2m42s
All checks were successful
itom-platform auto build image / build (push) Successful in 2m42s
This commit is contained in:
@@ -15,8 +15,13 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: git.imall.cloud
|
# 使用 Docker Hub 作为镜像仓库
|
||||||
IMAGE: git.imall.cloud/itom-group/chat-deploy
|
REGISTRY: docker.io
|
||||||
|
# Docker Hub 个人命名空间(需与 DOCKER_USERNAME 一致)
|
||||||
|
IMAGE: docker.io/kim6789/chat-deploy
|
||||||
|
# Docker Hub 凭证来自仓库 Secrets
|
||||||
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
steps:
|
steps:
|
||||||
- name: Install git
|
- name: Install git
|
||||||
shell: sh
|
shell: sh
|
||||||
@@ -117,47 +122,16 @@ jobs:
|
|||||||
- name: Login registry
|
- name: Login registry
|
||||||
shell: sh
|
shell: sh
|
||||||
env:
|
env:
|
||||||
GIT_USER: ${{ secrets.GIT_USER }}
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
|
||||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
AUTO_REGISTRY_USER: ${{ env.DOCKER_USERNAME }}
|
|
||||||
AUTO_REGISTRY_PASS: ${{ env.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
login_try() {
|
# 使用 Docker Hub 凭证登录
|
||||||
local user="$1"
|
if [ -z "${DOCKER_USERNAME:-}" ] || [ -z "${DOCKER_PASSWORD:-}" ]; then
|
||||||
local pass="$2"
|
echo "ERROR: 缺少 Docker Hub 凭证(DOCKER_USERNAME/DOCKER_PASSWORD)。"
|
||||||
local label="$3"
|
exit 1
|
||||||
if [ -z "$user" ] || [ -z "$pass" ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if echo "$pass" | docker login "$REGISTRY" -u "$user" --password-stdin >/dev/null 2>&1; then
|
|
||||||
echo "Registry login ok ($label)"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if login_try "$REGISTRY_USER" "$REGISTRY_PASSWORD" "REGISTRY_USER"; then
|
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
if login_try "$GIT_USER" "$GIT_TOKEN" "GIT_USER"; then
|
echo "$DOCKER_PASSWORD" | docker login "$REGISTRY" -u "$DOCKER_USERNAME" --password-stdin
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
if login_try "${AUTO_REGISTRY_USER:-}" "${AUTO_REGISTRY_PASS:-}" "AUTO_REGISTRY"; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
ACTOR="${GITEA_ACTOR:-${FORGEJO_ACTOR:-${GITHUB_ACTOR:-}}}"
|
|
||||||
JOB_TOKEN="${GITEA_TOKEN:-${FORGEJO_TOKEN:-${GITHUB_TOKEN:-}}}"
|
|
||||||
if login_try "$ACTOR" "$JOB_TOKEN" "JOB_TOKEN"; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "ERROR: registry login failed. Provide REGISTRY_USER/REGISTRY_PASSWORD or GIT_USER/GIT_TOKEN with packages write permission."
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
- name: Build and push images
|
- name: Build and push images
|
||||||
shell: sh
|
shell: sh
|
||||||
|
|||||||
Reference in New Issue
Block a user