This commit is contained in:
jeremygan2021
2026-02-13 13:32:35 +08:00
parent 1262ba1f9f
commit f89735dda2

View File

@@ -13,7 +13,9 @@ jobs:
image: catthehacker/ubuntu:act-latest image: catthehacker/ubuntu:act-latest
steps: steps:
- name: 检出代码 - name: 检出代码
uses: actions/checkout@v3 run: |
pwd
ls -la
# 1. 登录 Docker Registry (已跳过,无密码模式)1 # 1. 登录 Docker Registry (已跳过,无密码模式)1
# - name: 登录到私有 Registry # - name: 登录到私有 Registry
@@ -25,48 +27,31 @@ jobs:
# 2. 构建并推送镜像 # 2. 构建并推送镜像
- name: 配置 Buildx - name: 配置 Buildx
uses: docker/setup-buildx-action@v2 run: |
with: cat > buildkitd.toml << 'EOF'
driver-opts: network=host
buildkitd-flags: --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host
config-inline: |
[registry."docker.io"] [registry."docker.io"]
mirrors = ["https://docker.m.daocloud.io", "https://dockerproxy.com"] mirrors = ["https://docker.m.daocloud.io", "https://dockerproxy.com"]
[registry."121.43.104.161:6500"] [registry."121.43.104.161:6500"]
http = true http = true
insecure = 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 镜像 - name: 构建并推送 Docker 镜像
uses: docker/build-push-action@v4 run: |
with: docker buildx build --push --tag 121.43.104.161:6500/quant-speed-page:latest --allow security.insecure --allow network.host .
context: .
push: true
# 镜像标签,推送到私有 Registry
tags: 121.43.104.161:6500/quant-speed-page:latest
# 3. 部署到服务器 # 3. 部署到服务器
- name: 部署到服务器 - name: 部署到服务器
# uses: appleboy/ssh-action@master
# 换用 garygrossgarten/github-action-ssh它不依赖外部下载
uses: garygrossgarten/github-action-ssh@release
env: env:
QUANT_PASSWORD: ${{ secrets.QUANT_PASSWORD }} QUANT_PASSWORD: ${{ secrets.QUANT_PASSWORD }}
with: run: |
host: 121.40.192.128 apt-get update -y
port: 22 apt-get install -y sshpass
username: root sshpass -p "$QUANT_PASSWORD" ssh -o StrictHostKeyChecking=no -p 22 root@121.40.192.128 '
password: ${{ secrets.QUANT_PASSWORD }}
command: |
# 停止并删除旧容器
docker stop quant-speed-page || true docker stop quant-speed-page || true
docker rm quant-speed-page || true docker rm quant-speed-page || true
# 拉取最新镜像
docker pull 121.43.104.161:6500/quant-speed-page:latest 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