Automate validated site publishing to Tencent Makers (#1475)

This commit is contained in:
CyC2018
2026-10-28 02:05:32 +08:00
committed by GitHub
parent 8412b98577
commit f9ca2d9815
8 changed files with 1307 additions and 12 deletions
+78
View File
@@ -0,0 +1,78 @@
name: 网站构建与发布
on:
push:
branches: [master]
pull_request:
paths:
- '.github/workflows/website.yml'
- 'README.md'
- 'CONTRIBUTING.md'
- 'notes/**'
- 'assets/**'
- 'docs/_media/**'
- 'website/**'
schedule:
# UTC; Beijing time 09:17 and 21:17.
- cron: '17 1,13 * * *'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: website-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
website:
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-depth: 1
ref: ${{ github.event_name == 'pull_request' && github.ref || 'master' }}
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.12'
cache: pip
cache-dependency-path: website/requirements.txt
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '22'
- name: 安装固定版本依赖
run: |
python -m pip install -r website/requirements.txt
npm ci --prefix website/deploy --ignore-scripts
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: website/.cache/site-assets
key: site-webp-v1-${{ runner.os }}-${{ hashFiles('website/requirements.txt', 'website/builder/site_assets.py', 'notes/pics/**', 'assets/**') }}
restore-keys: site-webp-v1-${{ runner.os }}-
- name: 生成并校验网站与配图
run: python website/refresh.py --from-checkout
- name: 检查搜索和发布保护
run: |
python website/builder/test_site_assets.py
node website/builder/test_search.cjs
npm test --prefix website/deploy
- name: 发布网页和图片并校验正式域名
if: github.repository == 'CyC2018/CS-Notes' && github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
env:
EDGEONE_API_TOKEN: ${{ secrets.EDGEONE_API_TOKEN }}
run: node website/deploy/deploy.mjs
- name: 保留小型版本报告
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: website-report-${{ github.run_id }}-${{ github.run_attempt }}
path: |
website/dist/build-info.json
website/dist/asset-manifest.json
website/dist-report.json
website/validation.json
website/deployment-report.json
retention-days: 7
if-no-files-found: warn