two commit #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Cloudflare Pages | |
on: | |
workflow_dispatch: # 启用手动触发 | |
push: | |
branches: | |
- main # 默认分支 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
submodules: recursive | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" # 使用 LTS 版本 | |
- name: Cache NPM dependencies | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: ${{ runner.OS }}-npm-cache-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.OS }}-npm-cache | |
- name: Install Dependencies | |
run: npm install | |
- name: Install Hexo globally | |
run: npm install -g hexo-cli | |
- name: Build the site | |
run: npm run build | |
- name: Upload Pages artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./public | |
deploy: | |
needs: build | |
permissions: | |
pages: write | |
id-token: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to Cloudflare Pages | |
id: deployment | |
uses: cloudflare/pages-action@v2 | |
with: | |
api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }} # Cloudflare API token,记得在 GitHub secrets 中设置 | |
project-name: lovezbismih-github-io # Cloudflare Pages 项目名称 | |
branch: main # 部署的分支 | |
directory: ./public # 静态文件输出目录 |