Skip to content
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

重构 GitHub 工作流 #47

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Build on Pull Request
name: Build

on:
pull_request:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
# 如果你文档需要 Git 子模块,取消注释下一行
Expand All @@ -28,3 +28,11 @@ jobs:
NODE_OPTIONS: --max_old_space_size=8192
run: |-
npm run docs:build
> src/.vuepress/dist/.nojekyll

- name: Upload build result
uses: actions/upload-artifact@v3
with:
name: build-result
path: |
src/.vuepress/dist
44 changes: 0 additions & 44 deletions .github/workflows/deploy-docs.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy GitHub Pages

on:
workflow_call:

permissions:
contents: write

jobs:
deploy-gh-pages:
runs-on: ubuntu-latest
steps:
- name: Restore Build Result
uses: actions/download-artifact@v3
with:
name: build-result
path: ./src/.vuepress/dist

- name: Display structure of downloaded files
run: ls -R

- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
# 这是文档部署到的分支名称
branch: gh-pages
folder: src/.vuepress/dist
5 changes: 3 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Lint 文档
name: Lint Markdown

on: [push, pull_request]
on:
workflow_call:

jobs:
lint:
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Main Action

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: write

jobs:
lint:
uses: ./.github/workflows/lint.yml

build:
uses: ./.github/workflows/build.yml

deploy-gh-pages:
if: github.ref_name == 'main' && github.event_name == 'push'
needs:
- lint
- build
uses: ./.github/workflows/deploy-gh-pages.yml