Files
freedom-web/.gitea/workflows/deploy.yml
T
张家训 30531ce883
CI/CD Deploy (Web) / 构建前端镜像并部署 (push) Failing after 10m25s
fix: workflow 绉婚櫎 container options锛屾寕杞界敱 runner 閰嶇疆鎻愪緵
2026-08-26 11:40:17 +08:00

64 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.
# =============================================================
# freedom-web CI/CD 工作流(前端)
# 触发条件:push 到 master 分支时自动构建并部署
#
# 环境(同 freedom-admin,见其 workflow 注释):
# - runner labels: ubuntu-latest
# - job 容器挂载 /var/run/docker.sock 与 /opt/freedom(由 runner-config.toml 的 volumes 提供)
# - 部署目录:/opt/freedom/deploy
#
# 前置条件(管理员一次性完成):
# - 宿主 /opt/freedom/deploy/docker-compose.yml 与 .env 已就位
# (web 服务本身不需要数据库,但 compose 文件解析 backend 服务时需要)
# =============================================================
name: CI/CD Deploy (Web)
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build-and-deploy:
name: 构建前端镜像并部署
runs-on: ubuntu-latest
container:
image: docker:24.0-cli
# 注意:docker.sock 与 /opt/freedom 挂载由 runner-config.toml 提供,
# 不要在 options 中重复添加(act_runner v0.6.1 不合并 workflow 的 bind mount)
steps:
- name: 安装 git
run: apk add --no-cache git
- name: 拉取 master 代码
run: |
set -euo pipefail
rm -rf /opt/freedom/workspace-web
git clone --depth 1 --branch master \
"http://oauth2:${GITHUB_TOKEN}@host.docker.internal:3000/${GITHUB_REPOSITORY}.git" \
/opt/freedom/workspace-web
cd /opt/freedom/workspace-web
echo "==> 已拉取代码,最新提交:"
git log -1 --oneline
env:
GITHUB_TOKEN: ${{ github.token }}
- name: 构建前端镜像
run: |
set -euo pipefail
docker build -t freedom-web:latest /opt/freedom/workspace-web
- name: 部署前端服务
run: |
set -euo pipefail
cd /opt/freedom/deploy
test -f docker-compose.yml || { echo "错误: 缺少 docker-compose.yml,请先初始化部署目录"; exit 1; }
test -f .env || { echo "错误: 缺少 .env,请先初始化部署目录"; exit 1; }
docker compose up -d --force-recreate web
- name: 确认部署结果
run: |
cd /opt/freedom/deploy
docker compose ps web