From f89735dda28d5836578ec21b8006566b174d1602 Mon Sep 17 00:00:00 2001 From: jeremygan2021 Date: Fri, 13 Feb 2026 13:32:35 +0800 Subject: [PATCH] t --- .gitea/workflows/deploy.yaml | 57 +++++++++++++----------------------- 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 58d4c70..f584433 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -13,7 +13,9 @@ jobs: image: catthehacker/ubuntu:act-latest steps: - name: 检出代码 - uses: actions/checkout@v3 + run: | + pwd + ls -la # 1. 登录 Docker Registry (已跳过,无密码模式)1 # - name: 登录到私有 Registry @@ -25,48 +27,31 @@ jobs: # 2. 构建并推送镜像 - name: 配置 Buildx - uses: docker/setup-buildx-action@v2 - with: - driver-opts: network=host - buildkitd-flags: --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host - config-inline: | - [registry."docker.io"] - mirrors = ["https://docker.m.daocloud.io", "https://dockerproxy.com"] - [registry."121.43.104.161:6500"] - http = true - insecure = true + run: | + cat > buildkitd.toml << 'EOF' + [registry."docker.io"] + mirrors = ["https://docker.m.daocloud.io", "https://dockerproxy.com"] + [registry."121.43.104.161:6500"] + http = true + insecure = true + EOF + docker buildx create --name ci-builder --use --driver docker-container --driver-opt network=host --buildkitd-flags "--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host" --config ./buildkitd.toml + docker buildx inspect --bootstrap - name: 构建并推送 Docker 镜像 - uses: docker/build-push-action@v4 - with: - context: . - push: true - # 镜像标签,推送到私有 Registry - tags: 121.43.104.161:6500/quant-speed-page:latest + run: | + docker buildx build --push --tag 121.43.104.161:6500/quant-speed-page:latest --allow security.insecure --allow network.host . # 3. 部署到服务器 - name: 部署到服务器 - # uses: appleboy/ssh-action@master - # 换用 garygrossgarten/github-action-ssh,它不依赖外部下载 - uses: garygrossgarten/github-action-ssh@release env: QUANT_PASSWORD: ${{ secrets.QUANT_PASSWORD }} - with: - host: 121.40.192.128 - port: 22 - username: root - password: ${{ secrets.QUANT_PASSWORD }} - command: | - # 停止并删除旧容器 + run: | + apt-get update -y + apt-get install -y sshpass + sshpass -p "$QUANT_PASSWORD" ssh -o StrictHostKeyChecking=no -p 22 root@121.40.192.128 ' docker stop quant-speed-page || true docker rm quant-speed-page || true - - # 拉取最新镜像 docker pull 121.43.104.161:6500/quant-speed-page:latest - - # 启动新容器/ - docker run -d \ - --name quant-speed-page \ - --restart unless-stopped \ - -p 8080:80 \ - 121.43.104.161:6500/quant-speed-page:latest + docker run -d --name quant-speed-page --restart unless-stopped -p 8080:80 121.43.104.161:6500/quant-speed-page:latest + '