From f14fdf208ed7c0ebefac79b6f3b4ef32a3ef892d Mon Sep 17 00:00:00 2001 From: lingyuzeng Date: Wed, 1 Oct 2025 02:05:37 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/build-and?= =?UTF-8?q?-push.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit removev2fly --- .gitea/workflows/build-and-push.yml | 59 ----------------------------- 1 file changed, 59 deletions(-) diff --git a/.gitea/workflows/build-and-push.yml b/.gitea/workflows/build-and-push.yml index be80110..4573401 100644 --- a/.gitea/workflows/build-and-push.yml +++ b/.gitea/workflows/build-and-push.yml @@ -43,58 +43,6 @@ jobs: docker logout "$ACR_REGISTRY" || true echo "$ACR_PASSWORD" | docker login "$ACR_REGISTRY" --username "$ACR_USERNAME" --password-stdin - - name: Start v2ray-client (write + assert + verify + run + logs) - env: - V2RAY_JSON: ${{ secrets.V2RAY_JSON }} - SOCKS_PORT: "11080" - HTTP_PORT: "18080" - run: | - set -euo pipefail - - # 0) Secret 非空 - [ -n "${V2RAY_JSON:-}" ] || { echo "V2RAY_JSON is empty"; exit 1; } - - # 1) 在工作区生成 config.json,并将 inbounds 端口改成我们想要的 - mkdir -p "${GITHUB_WORKSPACE}/v2ray" - printf '%s' "$V2RAY_JSON" > "${GITHUB_WORKSPACE}/v2ray/config.json" - if command -v jq >/dev/null 2>&1; then - jq --argjson sp "$SOCKS_PORT" --argjson hp "$HTTP_PORT" \ - '.inbounds |= map( - if .protocol=="socks" and .port then .port=$sp - else if .protocol=="http" and .port then .port=$hp - else . end end - )' "${GITHUB_WORKSPACE}/v2ray/config.json" \ - > "${GITHUB_WORKSPACE}/v2ray/config.tmp" && mv "${GITHUB_WORKSPACE}/v2ray/config.tmp" "${GITHUB_WORKSPACE}/v2ray/config.json" - fi - - # 2) base64 编码(兼容不同实现) - if base64 --help 2>&1 | grep -q -- '-w'; then - CONF_B64="$(base64 -w0 < "${GITHUB_WORKSPACE}/v2ray/config.json")" - else - CONF_B64="$(base64 < "${GITHUB_WORKSPACE}/v2ray/config.json" | tr -d '\n')" - fi - - # 3) 以 host 网络启动;覆盖 ENTRYPOINT 为 /bin/sh,写配置后 exec v2ray - docker rm -f v2ray-client >/dev/null 2>&1 || true - docker run -d --name v2ray-client \ - --network host \ - -e CONF_B64="${CONF_B64}" \ - --entrypoint /bin/sh \ - v2fly/v2fly-core:latest \ - -lc 'set -euo pipefail; - mkdir -p /etc/v2ray; - printf "%s" "$CONF_B64" | base64 -d > /etc/v2ray/config.json; - exec /usr/bin/v2ray run -c /etc/v2ray/config.json' - - # 4) 健康检查 + 日志 - sleep 1 - if [ "$(docker inspect -f '{{.State.Running}}' v2ray-client 2>/dev/null)" != "true" ]; then - echo "== v2ray-client exited; logs ==" - docker logs v2ray-client || true - exit 1 - fi - echo "v2ray-client is running." - - name: Build Docker Image (host network; no Dockerfile change) env: IMAGE: ${{ secrets.ACR_REGISTRY }}/${{ secrets.ACR_NAMESPACE }}/${{ vars.IMAGE_NAME }} @@ -119,13 +67,6 @@ jobs: --load \ -t "${IMAGE}:${TAG}" -f docker/Dockerfile . - - name: Stop v2ray-client - if: always() # 确保出错也能清理 - run: | - set -euo pipefail - docker rm -f v2ray-client || true - rm -rf "${GITHUB_WORKSPACE}/v2ray-client.json" - - name: Push Docker Image env: IMAGE: ${{ secrets.ACR_REGISTRY }}/${{ secrets.ACR_NAMESPACE }}/${{ vars.IMAGE_NAME }}