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

ci: add docs deploy workflow #91

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion .dumirc.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
// more config: https://d.umijs.org/config
import { defineConfig } from 'dumi';

const name = 'cssinjs';

const isProdSite =
// 不是预览模式 同时是生产环境
process.env.PREVIEW !== 'true' && process.env.NODE_ENV === 'production';

export default defineConfig({
favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'],
themeConfig: {
name: 'cssinjs',
name,
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
},
outputPath: '.doc',
exportStatic: {},
base: isProdSite ? `/${name}/` : '/',
publicPath: isProdSite ? `/${name}/` : '/',
});
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
dist: .doc
build: |
npm install
npm run docs:build
npm run docs:preview
- name: Get the preview_url
run: echo "url => ${{ steps.preview_step.outputs.preview_url }}"
39 changes: 39 additions & 0 deletions .github/workflows/site-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy website
on:
push:
tags:
- '*'
workflow_dispatch:

permissions:
contents: write

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3

- name: setup node
uses: actions/setup-node@v1
with:
node-version: 14

- name: create package-lock.json
run: npm i --package-lock-only --ignore-scripts

- name: Install dependencies
run: npm ci

- name: build Docs
run: npm run docs:build

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./.doc
force_orphan: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
"start": "dumi dev",
"docs:build": "dumi build",
"docs:deploy": "gh-pages -d .doc",
Wxh16144 marked this conversation as resolved.
Show resolved Hide resolved
"docs:preview": "PREVIEW=true npm run docs:build",
"compile": "father build",
"gh-pages": "npm run docs:build && npm run docs:deploy",
"gh-pages": "npm run docs:build",
"prepublishOnly": "npm run compile && np --yolo --no-publish",
"postpublish": "npm run gh-pages",
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
Expand Down