-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# 自定义当前执行文件的名称 | ||
name: document | ||
# 整个流程在main分支发生push事件时触发 | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest # 运行在ubuntu-latest环境的虚拟机中 | ||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
steps: | ||
# 获取仓库源码 | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} # 步骤2 | ||
uses: actions/setup-node@v3 # 作用:安装nodejs | ||
with: | ||
node-version: ${{ matrix.node-version }} # 版本 | ||
# 构建和部署 | ||
- name: Deploy | ||
env: # 环境变量 | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} # 在仓库中配置的token | ||
run: npm install && npm run deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env sh | ||
|
||
# 确保脚本抛出遇到的错误 | ||
set -e | ||
|
||
# 生成静态文件 | ||
npm run build | ||
|
||
# 进入生成的文件夹 | ||
cd docs/.vuepress/dist | ||
|
||
# 如果是发布到自定义域名 | ||
echo 'blog.storyxc.com' > CNAME | ||
|
||
if [ -z "${GH_TOKEN}" ]; then | ||
echo "GH_TOKEN is not set" | ||
exit 1 | ||
else | ||
msg='github actions自动部署' | ||
githubUrl=https://storyxc:${GH_TOKEN}@github.com/storyxc/document.git | ||
git config --global user.name "storyxc" | ||
git config --global user.email "[email protected]" | ||
fi | ||
|
||
git init | ||
git add -A | ||
git commit -m "${msg}" | ||
|
||
git push -f "$githubUrl" master:gh-pages | ||
|
||
cd - | ||
|
||
rm -rf docs/.vuepress/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters