diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index bfb90ea..81a4944 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -24,7 +24,11 @@ concurrency: env: REGISTRY: docker.io - DOCKER_USER: ${{ secrets.DOCKER_USERNAME || 'mag1666888' }} + # Docker Hub 命名空间:itom-group + DOCKER_USER: itom-group + # Docker Hub 凭证来自仓库 Secrets + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} GO_VERSION: "1.24" jobs: @@ -122,8 +126,9 @@ jobs: uses: docker/login-action@v3.3.0 with: registry: ${{ env.REGISTRY }} - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + # 使用账号登录,镜像仍推送到 DOCKER_USER 命名空间 + username: ${{ env.DOCKER_USERNAME }} + password: ${{ env.DOCKER_PASSWORD }} - name: 设置 Docker Buildx uses: docker/setup-buildx-action@v3.8.0 @@ -532,4 +537,4 @@ jobs: echo "- \`$DOCKER_USER/openim-rpc-group:$VERSION_TAG\`" >> $GITHUB_STEP_SUMMARY echo "- \`$DOCKER_USER/openim-rpc-conversation:$VERSION_TAG\`" >> $GITHUB_STEP_SUMMARY echo "- \`$DOCKER_USER/openim-rpc-third:$VERSION_TAG\`" >> $GITHUB_STEP_SUMMARY - echo "- \`$DOCKER_USER/openim-rpc-msg:$VERSION_TAG\`" >> $GITHUB_STEP_SUMMARY \ No newline at end of file + echo "- \`$DOCKER_USER/openim-rpc-msg:$VERSION_TAG\`" >> $GITHUB_STEP_SUMMARY diff --git a/.gitea/workflows/itom-platform-auto-build.yml b/.gitea/workflows/itom-platform-auto-build.yml index 5b42ea7..3173df2 100644 --- a/.gitea/workflows/itom-platform-auto-build.yml +++ b/.gitea/workflows/itom-platform-auto-build.yml @@ -15,8 +15,10 @@ jobs: runs-on: openim env: - REGISTRY: git.imall.cloud - IMAGE: git.imall.cloud/itom-group/open-im-server-deploy + # 使用 Docker Hub 作为镜像仓库 + REGISTRY: docker.io + # Docker Hub 命名空间:itom-group + IMAGE: docker.io/itom-group/open-im-server-deploy steps: - name: Install git shell: sh @@ -117,47 +119,17 @@ jobs: - name: Login registry shell: sh env: - GIT_USER: ${{ secrets.GIT_USER }} - GIT_TOKEN: ${{ secrets.GIT_TOKEN }} - REGISTRY_USER: ${{ secrets.REGISTRY_USER }} - REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} - AUTO_REGISTRY_USER: ${{ secrets.DOCKER_USERNAME }} - AUTO_REGISTRY_PASS: ${{ secrets.DOCKER_PASSWORD }} - + # Docker Hub 凭证来自仓库 Secrets + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} run: | set -eu - login_try() { - local user="$1" - local pass="$2" - 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 + # 使用 Docker Hub 凭证登录,统一仓库镜像出口 + if [ -z "${DOCKER_USERNAME:-}" ] || [ -z "${DOCKER_PASSWORD:-}" ]; then + echo "ERROR: 缺少 Docker Hub 凭证(DOCKER_USERNAME/DOCKER_PASSWORD)。" + exit 1 fi - 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 + echo "$DOCKER_PASSWORD" | docker login "$REGISTRY" -u "$DOCKER_USERNAME" --password-stdin - name: Build and push images shell: sh