chore: add itom-platform auto build workflow
Some checks failed
itom-platform auto build image / build (push) Failing after 2m33s
Some checks failed
itom-platform auto build image / build (push) Failing after 2m33s
This commit is contained in:
@@ -15,42 +15,16 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# 使用 Docker Hub 作为镜像仓库
|
REGISTRY: git.imall.cloud
|
||||||
REGISTRY: docker.io
|
IMAGE: git.imall.cloud/itom-group/chat-deploy
|
||||||
# Docker Hub 个人命名空间(需与 DOCKER_USERNAME 一致)
|
|
||||||
IMAGE: docker.io/kim6789/chat-deploy
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install git
|
- name: Install git
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
if command -v git >/dev/null 2>&1; then
|
if ! command -v git >/dev/null 2>&1; then
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
if command -v apt-get >/dev/null 2>&1; then
|
|
||||||
if command -v sudo >/dev/null 2>&1; then
|
|
||||||
sudo apt-get update -y
|
|
||||||
sudo apt-get install -y git openssh-client ca-certificates
|
|
||||||
else
|
|
||||||
apt-get update -y
|
|
||||||
apt-get install -y git openssh-client ca-certificates
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
if command -v apk >/dev/null 2>&1; then
|
|
||||||
apk add --no-cache git openssh-client ca-certificates
|
apk add --no-cache git openssh-client ca-certificates
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
if command -v yum >/dev/null 2>&1; then
|
|
||||||
if command -v sudo >/dev/null 2>&1; then
|
|
||||||
sudo yum install -y git openssh-clients ca-certificates
|
|
||||||
else
|
|
||||||
yum install -y git openssh-clients ca-certificates
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "ERROR: no supported package manager found to install git."
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
shell: sh
|
shell: sh
|
||||||
@@ -143,17 +117,47 @@ jobs:
|
|||||||
- name: Login registry
|
- name: Login registry
|
||||||
shell: sh
|
shell: sh
|
||||||
env:
|
env:
|
||||||
# Docker Hub 凭证来自仓库 Secrets
|
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
|
||||||
# 使用 Docker Hub 凭证登录,避免触发私有仓库上传限制
|
login_try() {
|
||||||
if [ -z "${DOCKER_USERNAME:-}" ] || [ -z "${DOCKER_PASSWORD:-}" ]; then
|
local user="$1"
|
||||||
echo "ERROR: 缺少 Docker Hub 凭证(DOCKER_USERNAME/DOCKER_PASSWORD)。"
|
local pass="$2"
|
||||||
exit 1
|
local label="$3"
|
||||||
|
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
|
||||||
echo "$DOCKER_PASSWORD" | docker login "$REGISTRY" -u "$DOCKER_USERNAME" --password-stdin
|
if login_try "$GIT_USER" "$GIT_TOKEN" "GIT_USER"; then
|
||||||
|
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