-
Notifications
You must be signed in to change notification settings - Fork 0
添加 GitHub Actions 自动部署工作流 #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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: | ||
| node-version: '16' | ||
| cache: 'npm' | ||
|
|
||
| - name: 安装依赖 | ||
|
Comment on lines
+17
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Suggested implementation: |
||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: CNAME is configured in two places (manual file creation and The workflow currently both writes |
||
There was a problem hiding this comment.
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-providerflag below.Suggested implementation: