Files
quant-speed_page/.gitea/workflows/deploy.yaml
jeremygan2021 d4bacf669a t
2026-02-13 13:34:32 +08:00

73 lines
2.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: 构建并部署
run-name: ${{ gitea.actor }} 正在部署 Quant Speed Page 🚀
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu
container:
image: catthehacker/ubuntu:act-latest
steps:
- name: 检出代码
uses: actions/checkout@v3
# 1. 登录 Docker Registry (已跳过,无密码模式)1
# - name: 登录到私有 Registry
# uses: docker/login-action@v2
# with:
# registry: 121.43.104.161:6500
# username: ${{ secrets.DOCKER_REGISTRY_USER }}
# password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
# 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
- name: 构建并推送 Docker 镜像
uses: docker/build-push-action@v4
with:
context: .
push: true
# 镜像标签,推送到私有 Registry
tags: 121.43.104.161:6500/quant-speed-page:latest
# 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: |
# 停止并删除旧容器
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