92 lines
3.5 KiB
YAML
92 lines
3.5 KiB
YAML
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"
|