Files
freedom-web/.gitea/workflows/deploy.yml
T
yiciheng 609c88bd46
CI/CD Deploy (Web) / 构建前端镜像并部署 (push) Failing after 10m23s
ci: 改用 container.options 挂载 /opt/freedom(docker.sock 由 runner 自动挂载)
2026-08-31 14:33:16 +08:00

61 lines
2.1 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:
# - /var/run/docker.sock 由 act_runner 自动挂载,不可重复声明
# - /opt/freedom 经 container.options 的 -v 挂载(依赖 valid_volumes 白名单)
# - host.docker.internal 由 options 的 --add-host 解析
# - act_runner 不自动检出代码,需自行 git clone
# - 部署目录:/opt/freedom/deploy
# =============================================================
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
options: -v /opt/freedom:/opt/freedom --add-host=host.docker.internal:host-gateway
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