Files
homepage/.gitea/workflows/deploy-cloud.yml
dafe 02816ed932
All checks were successful
部署-局域网 / deploy (push) Successful in 3s
ci: Gitea Actions 流水线(push 自动部署局域网,云端手动审核发布)
2026-11-02 15:11:06 +08:00

35 lines
1.4 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.

name: 发布-云端
# 仅人工触发(Gitea 网页 Actions 页点 Run workflow)= 审核发布
on:
workflow_dispatch: {}
jobs:
deploy:
runs-on: build-runner
steps:
- name: 拉取代码
run: |
git clone --depth 1 "http://dafe:${{ secrets.GITHUB_TOKEN }}@192.168.51.66:3000/dafe/homepage.git" site
- name: 注入构建版本号(缓存击穿,版本=commit 短 SHA)
run: |
cd site
sed -i "s/?v=[0-9]*/?v=${GITHUB_SHA:0:8}/g" index.html
- name: 发布到 ubuntu3(公网 www.shashann.com)
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
run: |
mkdir -p ~/.ssh && chmod 700 ~/.ssh
printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H 124.222.157.76 >> ~/.ssh/known_hosts 2>/dev/null
cd site
ssh ubuntu@124.222.157.76 'mkdir -p /var/www/shashann-homepage && find /var/www/shashann-homepage -mindepth 1 -maxdepth 1 -exec rm -rf {} +'
tar czf - index.html assets | ssh ubuntu@124.222.157.76 'tar xzf - -C /var/www/shashann-homepage'
- name: 上线验证
run: |
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')"