Skip to content

Commit

Permalink
Refactor GitHub action workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
northword committed Oct 7, 2023
1 parent 3fa98e5 commit c196a86
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 49 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/build-on-pr.yml → .github/workflows/build.yml
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

0 comments on commit c196a86

Please sign in to comment.