81 lines
2.2 KiB
YAML
81 lines
2.2 KiB
YAML
name: Deploy to UpYun
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main # 根据您的实际情况修改分支名称
|
|
schedule:
|
|
- cron: '0 */12 * * *' # 每十二小时自动构建一次
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Setup Hugo
|
|
uses: peaceiris/actions-hugo@v2
|
|
with:
|
|
hugo-version: '0.128.2'
|
|
extended: true
|
|
|
|
- name: Run Pre-Build Scripts
|
|
shell: pwsh
|
|
run: |
|
|
# 1. 自动生成友链 JSON (即使本地漏提交也能保证是最新的)
|
|
./scripts/update_link_lite_json.ps1
|
|
|
|
# 2. 自动处理隐藏文章 (防止 status: hidden 的文章意外泄露)
|
|
./scripts/add_draft_to_hidden.ps1
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '18'
|
|
|
|
- name: Install Node.js dependencies
|
|
run: npm install
|
|
|
|
- name: Generate Friend Circle Data
|
|
run: node scripts/generate_circle_data.js
|
|
|
|
- name: Build
|
|
run: rm -rf public && hugo --minify
|
|
|
|
- name: Debug Environment Variables
|
|
run: |
|
|
echo "Bucket: ${{ secrets.UPYUN_BUCKET }}"
|
|
echo "Operator: ${{ secrets.UPYUN_OPERATOR }}"
|
|
# 不推荐打印密码,但可以确认是否为空字符串
|
|
if [ -z "${{ secrets.UPYUN_PASSWORD }}" ]; then
|
|
echo "Password is empty or not set"
|
|
else
|
|
echo "Password is set"
|
|
fi
|
|
|
|
- name: Deploy to UpYun
|
|
uses: her-cat/upyun-deployer@v1.0.3
|
|
with:
|
|
bucket: ${{ secrets.UPYUN_BUCKET }}
|
|
operator: ${{ secrets.UPYUN_OPERATOR }}
|
|
password: ${{ secrets.UPYUN_PASSWORD }}
|
|
dir: 'public' # 确认这个目录是您的构建输出目录
|
|
publish_dir: '/' # 发布到 UpYun 的根目录
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.x'
|
|
|
|
- name: Install dependencies
|
|
run: pip install requests
|
|
|
|
- name: Refresh DogeCloud CDN
|
|
env:
|
|
DOGECLOUD_ACCESS_KEY: ${{ secrets.DOGECLOUD_ACCESS_KEY }}
|
|
DOGECLOUD_SECRET_KEY: ${{ secrets.DOGECLOUD_SECRET_KEY }}
|
|
CDN_URL_LIST: ${{ secrets.CDN_URL_LIST }}
|
|
run: python scripts/RefreshCDN.py
|