ci: 云端发布改为 tag 触发(push v* 即审核发布),clone 动态 ref
All checks were successful
部署-局域网 / deploy (push) Successful in 4s
发布-云端 / deploy (push) Successful in 7s

This commit is contained in:
dafe
2026-11-02 15:15:40 +08:00
parent 02816ed932
commit 22cd96a948
2 changed files with 12 additions and 9 deletions

View File

@@ -1,20 +1,22 @@
name: 发布-云端 name: 发布-云端
# 仅人工触发(Gitea 网页 Actions 页点 Run workflow)= 审核发布 # 审核 = 人工决定打不打 tag:push v* 标签即发布公网
# 发布历史 = git tag 列表(git tag -l 'v*'),发布版本号 = tag 名
on: on:
workflow_dispatch: {} push:
tags: ['v*']
jobs: jobs:
deploy: deploy:
runs-on: build-runner runs-on: build-runner
steps: steps:
- name: 拉取代码 - name: 拉取代码(tag 版本)
run: | run: |
git clone --depth 1 "http://dafe:${{ secrets.GITHUB_TOKEN }}@192.168.51.66:3000/dafe/homepage.git" site git clone --depth 1 --branch "${GITHUB_REF_NAME}" "http://dafe:${{ secrets.GITHUB_TOKEN }}@192.168.51.66:3000/dafe/homepage.git" site
- name: 注入构建版本号(缓存击穿,版本=commit 短 SHA) - name: 注入发布版本号(缓存击穿,版本=tag 名)
run: | run: |
cd site cd site
sed -i "s/?v=[0-9]*/?v=${GITHUB_SHA:0:8}/g" index.html sed -i "s/?v=[0-9]*/?v=${GITHUB_REF_NAME}/g" index.html
- name: 发布到 ubuntu3(公网 www.shashann.com) - name: 发布到 ubuntu3(公网 www.shashann.com)
env: env:
@@ -31,4 +33,4 @@ jobs:
- name: 上线验证 - name: 上线验证
run: | run: |
curl -s -f -o /dev/null --resolve www.shashann.com:443:124.222.157.76 https://www.shashann.com/ || { echo "❌ 公网验证失败"; exit 1; } curl -s -f -o /dev/null --resolve www.shashann.com:443:124.222.157.76 https://www.shashann.com/ || { echo "❌ 公网验证失败"; exit 1; }
echo "✅ 云端已发布 $(date '+%H:%M:%S')" echo "✅ 云端已发布 ${GITHUB_REF_NAME} $(date '+%H:%M:%S')"

View File

@@ -1,5 +1,6 @@
name: 部署-局域网 name: 部署-局域网
# push 到 main 即自动上线 51.66(无人工环节) # 合并/推送到 main 即自动上线 51.66(集成分支 = 内部预发布环境)
# feature 分支的 push 不触发,开发期不影响线上
on: on:
push: push:
branches: [main] branches: [main]
@@ -10,7 +11,7 @@ jobs:
steps: steps:
- name: 拉取代码 - name: 拉取代码
run: | run: |
git clone --depth 1 "http://dafe:${{ secrets.GITHUB_TOKEN }}@192.168.51.66:3000/dafe/homepage.git" site git clone --depth 1 --branch "${GITHUB_REF_NAME}" "http://dafe:${{ secrets.GITHUB_TOKEN }}@192.168.51.66:3000/dafe/homepage.git" site
- name: 注入构建版本号(缓存击穿,版本=commit 短 SHA) - name: 注入构建版本号(缓存击穿,版本=commit 短 SHA)
run: | run: |