@@ -0,0 +1,91 @@
|
|||||||
|
name: Salon SIT 自动发布
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- sit
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: jayucloud
|
||||||
|
env:
|
||||||
|
GITHUB_SERVER_URL: http://192.168.5.15:3000
|
||||||
|
WEB_TARGET_HOST: ${{ secrets.SALON_PROD_WEB_HOST }}
|
||||||
|
WEB_TARGET_PORT: ${{ secrets.SALON_PROD_WEB_PORT }}
|
||||||
|
WEB_TARGET_USER: ${{ secrets.SALON_PROD_WEB_USER }}
|
||||||
|
WEB_REMOTE_DIR: /opt/jc-salon-frontend-sit
|
||||||
|
steps:
|
||||||
|
- name: 从内网 Gitea 检出代码
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
test -n "$GITEA_TOKEN"
|
||||||
|
git init .
|
||||||
|
git remote add origin "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git"
|
||||||
|
git -c http.extraheader="Authorization: token $GITEA_TOKEN" fetch --no-tags --depth=1 origin "$GITHUB_SHA"
|
||||||
|
git checkout --detach "$GITHUB_SHA"
|
||||||
|
- name: 检查发布工具链
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
java -version 2>&1 | grep -q '17\.'
|
||||||
|
node --version | grep -q '^v20\.'
|
||||||
|
mvn --version | grep -q 'Java version: 17\.'
|
||||||
|
pwsh --version
|
||||||
|
- name: 构建 Salon SIT 发布包
|
||||||
|
shell: pwsh
|
||||||
|
run: >-
|
||||||
|
./docs/scripts/deploy-jayucloud-salon-production.ps1
|
||||||
|
-PackageOnly
|
||||||
|
-SkipTests
|
||||||
|
-SkipDatabaseInit
|
||||||
|
- name: 写入 SIT SSH 配置和目标清单
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
SALON_PROD_SSH_PRIVATE_KEY: ${{ secrets.SALON_PROD_SSH_PRIVATE_KEY }}
|
||||||
|
SALON_PROD_KNOWN_HOSTS: ${{ secrets.SALON_PROD_KNOWN_HOSTS }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
test -n "$SALON_PROD_SSH_PRIVATE_KEY"
|
||||||
|
test -n "$SALON_PROD_KNOWN_HOSTS"
|
||||||
|
test -n "$WEB_TARGET_HOST"
|
||||||
|
test -n "$WEB_TARGET_PORT"
|
||||||
|
test -n "$WEB_TARGET_USER"
|
||||||
|
mkdir -p "$RUNNER_TEMP/salon-sit"
|
||||||
|
printf '%s\n' "$SALON_PROD_SSH_PRIVATE_KEY" > "$RUNNER_TEMP/salon-sit/id_ed25519"
|
||||||
|
printf '%s\n' "$SALON_PROD_KNOWN_HOSTS" > "$RUNNER_TEMP/salon-sit/known_hosts"
|
||||||
|
chmod 600 "$RUNNER_TEMP/salon-sit/id_ed25519" "$RUNNER_TEMP/salon-sit/known_hosts"
|
||||||
|
cat > "$RUNNER_TEMP/salon-sit/servers.json" <<JSON
|
||||||
|
[
|
||||||
|
{"Name":"sit-app01","Host":"192.168.10.106","Port":22,"User":"root","Purpose":"Salon SIT Core/Gateway","Environment":"sit"},
|
||||||
|
{"Name":"salon-web-sit","Host":"${WEB_TARGET_HOST}","Port":${WEB_TARGET_PORT},"User":"${WEB_TARGET_USER}","Purpose":"Salon SIT NGINX","Environment":"sit"}
|
||||||
|
]
|
||||||
|
JSON
|
||||||
|
- name: 自动发布 Salon SIT
|
||||||
|
shell: pwsh
|
||||||
|
env:
|
||||||
|
SSH_KEY_PATH: ${{ runner.temp }}/salon-sit/id_ed25519
|
||||||
|
KNOWN_HOSTS_PATH: ${{ runner.temp }}/salon-sit/known_hosts
|
||||||
|
SERVER_INFO_JSON: ${{ runner.temp }}/salon-sit/servers.json
|
||||||
|
run: >-
|
||||||
|
./docs/scripts/deploy-jayucloud-salon-production.ps1
|
||||||
|
-Deploy
|
||||||
|
-SkipDatabaseInit
|
||||||
|
-AllowSitTarget
|
||||||
|
-RequireSystemd
|
||||||
|
-PackageDirectory "artifacts/release"
|
||||||
|
-ServerInfoJsonPath "$env:SERVER_INFO_JSON"
|
||||||
|
-SshKeyPath "$env:SSH_KEY_PATH"
|
||||||
|
-KnownHostsPath "$env:KNOWN_HOSTS_PATH"
|
||||||
|
-CoreRemoteAppDir "/opt/jc-salon-core-sit"
|
||||||
|
-GatewayRemoteAppDir "/opt/jc-salon-gateway-sit"
|
||||||
|
-CoreServiceName "jc-salon-core-sit"
|
||||||
|
-GatewayServiceName "jc-salon-gateway-sit"
|
||||||
|
-CoreHealthPort 181
|
||||||
|
-GatewayHealthPort 180
|
||||||
|
-WebTargetName "salon-web-sit"
|
||||||
|
-WebRemoteDir "$env:WEB_REMOTE_DIR"
|
||||||
|
-PublicBaseUrl "https://sit.yunail.art"
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# Salon SIT 自动发布配置
|
||||||
|
|
||||||
|
推送到 `sit` 分支后,`.gitea/workflows/salon-sit-deploy.yml` 自动构建并部署 Salon Core、Gateway 和前端;数据库 SQL 只随发布包归档,不自动执行。
|
||||||
|
|
||||||
|
## 部署目标
|
||||||
|
|
||||||
|
- Core/Gateway:`192.168.10.106:22`,独立目录 `/opt/jc-salon-core-sit`、`/opt/jc-salon-gateway-sit`,服务名 `jc-salon-core-sit`、`jc-salon-gateway-sit`。
|
||||||
|
- 前端:与生产共用阿里云入口服务器,独立目录 `/opt/jc-salon-frontend-sit`,域名 `sit.yunail.art`。
|
||||||
|
- SIT 中间件:Nacos `192.168.10.103:8848`、MySQL `192.168.10.102:3306`、Redis `192.168.10.101:6379`、RabbitMQ `192.168.10.104:5672`,由 SIT Nacos 配置注入。
|
||||||
|
- 工作流显式传入 `-AllowSitTarget`,仅允许 `Environment=sit` 的目标;生产工作流不传入该开关,仍拒绝非生产节点。
|
||||||
|
|
||||||
|
## 前置配置
|
||||||
|
|
||||||
|
1. Gitea Secrets 中已有的 `SALON_PROD_SSH_PRIVATE_KEY`、`SALON_PROD_KNOWN_HOSTS` 和 `SALON_PROD_WEB_*` 用于连接同一阿里云前端服务器;`known_hosts` 必须包含 `192.168.10.106`。
|
||||||
|
2. 阿里云 Nginx 新增 `sit.yunail.art` server 配置,将站点根目录指向 `/opt/jc-salon-frontend-sit`,并按现有生产规则代理 `/api`。
|
||||||
|
3. Nginx 修改后执行 `nginx -t`,通过后再 reload。
|
||||||
|
4. 首次部署前确认 `192.168.10.106` 已安装 Java 17、systemd 可用,且网络可访问 SIT Nacos、MySQL、Redis 和 RabbitMQ。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
- 推送 `sit` 后确认工作流完成 Core/Gateway 健康检查和前端文件发布。
|
||||||
|
- 检查 `https://sit.yunail.art/`、`/health/check` 及前端静态资源均返回 200。
|
||||||
|
- 检查 Nacos `jayucloud-salon` namespace 中服务注册状态和 SIT 配置读取。
|
||||||
@@ -9,6 +9,7 @@ param(
|
|||||||
[switch]$AllowDirtyWorkingTree,
|
[switch]$AllowDirtyWorkingTree,
|
||||||
[switch]$SkipDatabaseInit,
|
[switch]$SkipDatabaseInit,
|
||||||
[switch]$PackageOnly,
|
[switch]$PackageOnly,
|
||||||
|
[switch]$AllowSitTarget,
|
||||||
[switch]$RequireSystemd,
|
[switch]$RequireSystemd,
|
||||||
[string]$PackageDirectory = "",
|
[string]$PackageDirectory = "",
|
||||||
[string]$ServerInfoJsonPath = "",
|
[string]$ServerInfoJsonPath = "",
|
||||||
@@ -379,14 +380,18 @@ function Resolve-ServerInfoPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Assert-ProductionTarget {
|
function Assert-ProductionTarget {
|
||||||
param([object[]]$Servers)
|
param(
|
||||||
|
[object[]]$Servers,
|
||||||
|
[switch]$AllowSit
|
||||||
|
)
|
||||||
|
|
||||||
$blocked = @($Servers | Where-Object { $_.Name -match "^(?i:MessageHub|mysql|nacos|redis|rabbitmq)" })
|
$blocked = @($Servers | Where-Object { $_.Name -match "^(?i:MessageHub|mysql|nacos|redis|rabbitmq)" })
|
||||||
if ($blocked.Count -gt 0) {
|
if ($blocked.Count -gt 0) {
|
||||||
throw "拒绝把应用发布到基础设施节点:$($blocked.Name -join ', ')"
|
throw "拒绝把应用发布到基础设施节点:$($blocked.Name -join ', ')"
|
||||||
}
|
}
|
||||||
|
|
||||||
$knownNonProduction = @($Servers | Where-Object { $_.Environment -match "(?i)\b(dev|test|local|staging)\b" })
|
$blockedEnvironments = if ($AllowSit) { "(?i)\b(dev|test|local|staging)\b" } else { "(?i)\b(dev|test|local|staging|sit)\b" }
|
||||||
|
$knownNonProduction = @($Servers | Where-Object { $_.Environment -match $blockedEnvironments })
|
||||||
if ($knownNonProduction.Count -gt 0) {
|
if ($knownNonProduction.Count -gt 0) {
|
||||||
throw "拒绝发布到非生产环境节点:$($knownNonProduction.Name -join ', ')"
|
throw "拒绝发布到非生产环境节点:$($knownNonProduction.Name -join ', ')"
|
||||||
}
|
}
|
||||||
@@ -919,7 +924,7 @@ if ((-not $SkipDatabaseInit) -and $databaseServers.Count -ne 1) {
|
|||||||
throw "数据库初始化目标必须唯一,当前按 $DatabaseTargetName 找到 $($databaseServers.Count) 个。"
|
throw "数据库初始化目标必须唯一,当前按 $DatabaseTargetName 找到 $($databaseServers.Count) 个。"
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert-ProductionTarget (@($coreServers) + @($gatewayServers) + @($webServers))
|
Assert-ProductionTarget (@($coreServers) + @($gatewayServers) + @($webServers)) -AllowSit:$AllowSitTarget
|
||||||
$databaseServer = if (-not $SkipDatabaseInit) { $databaseServers[0] } else { $null }
|
$databaseServer = if (-not $SkipDatabaseInit) { $databaseServers[0] } else { $null }
|
||||||
|
|
||||||
Write-Host "服务器清单:$resolvedServerInfoPath"
|
Write-Host "服务器清单:$resolvedServerInfoPath"
|
||||||
|
|||||||
@@ -13,9 +13,22 @@
|
|||||||
| gateway01-02 | 生产 | Salon Gateway | `192.168.10.27` | 22 | Rocky Linux 9.8 | 17.0.20.1 | `/opt/jc-salon-gateway` | 已创建发布、备份、日志目录;服务单元待首次部署创建 |
|
| gateway01-02 | 生产 | Salon Gateway | `192.168.10.27` | 22 | Rocky Linux 9.8 | 17.0.20.1 | `/opt/jc-salon-gateway` | 已创建发布、备份、日志目录;服务单元待首次部署创建 |
|
||||||
| gateway01-03 | 生产 | Salon Gateway | `192.168.20.18` | 22 | Rocky Linux 9.8 | 17.0.20.1 | `/opt/jc-salon-gateway` | 已创建发布、备份、日志目录;服务单元待首次部署创建 |
|
| gateway01-03 | 生产 | Salon Gateway | `192.168.20.18` | 22 | Rocky Linux 9.8 | 17.0.20.1 | `/opt/jc-salon-gateway` | 已创建发布、备份、日志目录;服务单元待首次部署创建 |
|
||||||
|
|
||||||
|
## SIT 后端服务器
|
||||||
|
|
||||||
|
| 名称 | 环境 | 角色 | IP 地址 | SSH 端口 | 操作系统 | Java | 应用目录 | systemd 服务名 | 当前状态 |
|
||||||
|
| ---------- | ---- | ---------------- | ---------------- | ------: | -------------- | ---- | -------------------------------- | ------------------------------- | -------------------- |
|
||||||
|
| sit-app01 | SIT | Salon Core/Gateway | `192.168.10.106` | 22 | Rocky Linux 9.8 | 17 | `/opt/jc-salon-core-sit`、`/opt/jc-salon-gateway-sit` | `jc-salon-core-sit`、`jc-salon-gateway-sit` | 待首次自动部署创建 |
|
||||||
|
|
||||||
|
## SIT 前端入口
|
||||||
|
|
||||||
|
| 名称 | 环境 | 角色 | 入口域名 | 部署目录 | 说明 |
|
||||||
|
| ------------- | ---- | ---------- | ----------------- | -------------------------------- | ----------------------------------------- |
|
||||||
|
| aliyun01-web | SIT | Salon Nginx | `sit.yunail.art` | `/opt/jc-salon-frontend-sit` | 与生产前端共用阿里云服务器,通过域名区分 |
|
||||||
|
|
||||||
## 统一基线
|
## 统一基线
|
||||||
|
|
||||||
- 6 台服务器 SSH 端口均为 `22`,账号密码均为root,122503wcy....,防火墙由 firewalld 管理并处于运行状态。
|
- 6 台服务器 SSH 端口均为 `22`,账号密码均为root,122503wcy....,防火墙由 firewalld 管理并处于运行状态。
|
||||||
- 应用目录及其 `releases`、`backups`、`logs` 子目录权限均为 `755 root:root`。
|
- 应用目录及其 `releases`、`backups`、`logs` 子目录权限均为 `755 root:root`。
|
||||||
- 当前未创建或启动 `jc-salon-core`、`jc-salon-gateway` systemd 服务,80/81 业务端口未监听。
|
- 当前未创建或启动 `jc-salon-core`、`jc-salon-gateway` systemd 服务,80/81 业务端口未监听。
|
||||||
- 生产 SSH 凭据、Nacos 凭据和部署私钥由私有凭据管理,不写入本清单。
|
- 生产 SSH 凭据、Nacos 凭据和部署私钥由私有凭据管理,不写入本清单。
|
||||||
|
- SIT 应用 SSH 端口、账号和凭据沿用生产部署凭据;SIT 使用独立 systemd 服务、应用目录和 Nginx 站点目录,不得复用生产目录。
|
||||||
|
|||||||
Reference in New Issue
Block a user