Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 部署到 GitHub Pages

on:
push:
branches:
- develop # 当推送到 develop 分支时触发
workflow_dispatch: # 允许手动触发

permissions:
contents: write # 允许推送到 gh-pages 分支

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: 检出代码
uses: actions/checkout@v3

- name: 设置 Node.js
uses: actions/setup-node@v3
with:
Comment on lines +20 to +22

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Consider upgrading the Node.js runtime from 16 to an actively supported LTS (e.g., 18 or 20).

Node 16 is EOL, so it no longer receives security patches and may break with newer dependencies. If feasible, move to a current LTS (18 or 20) to reduce maintenance risk and potentially drop the --openssl-legacy-provider flag below.

Suggested implementation:

      - name: 设置 Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '20'
          cache: 'npm'

      - name: 构建项目
        run: npm run build

node-version: '16'
cache: 'npm'

- name: 安装依赖
Comment on lines +17 to +26

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Consider pinning GitHub Actions to specific commit SHAs for better supply-chain security.

Floating tags like @v3 implicitly trust any future changes to that tag. For stronger integrity, pin actions/checkout, actions/setup-node, and peaceiris/actions-gh-pages to specific commit SHAs, optionally keeping the major tag in a comment for clarity. This helps prevent unexpected behavior or supply-chain compromise from action updates.

Suggested implementation:

      - name: 检出代码
        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v3

      - name: 设置 Node.js
        uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v3

      - name: 部署到 GitHub Pages
        uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3

run: npm ci

- name: 构建项目
run: NODE_OPTIONS=--openssl-legacy-provider npm run build

- name: 添加 CNAME 文件
run: echo "kalman.l2k.tech" > dist/CNAME

- name: 部署到 GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
publish_branch: gh-pages # 部署到 gh-pages 分支
cname: kalman.l2k.tech
Comment on lines +32 to +41

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: CNAME is configured in two places (manual file creation and cname input), which is redundant and can become inconsistent.

The workflow currently both writes dist/CNAME and sets cname: kalman.l2k.tech on peaceiris/actions-gh-pages. Either one is enough; keeping both risks them diverging if the domain changes. Please choose a single mechanism, e.g. just the action’s cname input.