-
Notifications
You must be signed in to change notification settings - Fork 0
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
2 changed files
with
94 additions
and
0 deletions.
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,48 @@ | ||
name: Hexo1's Blog CI/CD # 脚本 workflow 名称 | ||
|
||
on: | ||
push: | ||
branches: [main] # 当监测 main,master 的 push | ||
paths: # 监测所有 source 目录下的文件变动,所有 yml,json 后缀文件的变动。 | ||
- '*.json' | ||
- '**.yml' | ||
- '**/source/**' | ||
|
||
jobs: | ||
blog: # 任务名称 | ||
timeout-minutes: 30 # 设置 30 分钟超时 | ||
runs-on: ubuntu-latest # 指定最新 ubuntu 系统 | ||
steps: | ||
- uses: actions/checkout@v2 # 拉取仓库代码 | ||
- uses: actions/setup-node@v2 # 设置 node.js 环境 | ||
- name: Cache node_modules # 缓存 node_modules,提高编译速度,毕竟每月只有 2000 分钟。 | ||
uses: actions/cache@v2 # 亲测 Github 服务器编译速度比我自己电脑都快,如果每次构建按5分钟计算,我们每个月可以免费部署 400 次,Github yyds!!! | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- name: Init Node.js # 安装源代码所需插件 | ||
run: | | ||
npm install | ||
echo "init node successful" | ||
- name: Install Hexo-cli # 安装 Hexo | ||
run: | | ||
npm install -g hexo-cli --save | ||
echo "install hexo successful" | ||
- name: Build Blog # 编译创建静态博客文件 | ||
run: | | ||
hexo clean | ||
hexo g | ||
echo "build blog successful" | ||
- name: Deploy hexo1's Blog # 设置 git 信息并推送静态博客文件 | ||
run: | | ||
git config --global user.name "ruY9527" | ||
git config --global user.email "[email protected]" | ||
hexo deploy | ||
- run: echo "Deploy Successful!" |
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,46 @@ | ||
name: Deploy site files | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # 只在master上push触发部署 | ||
paths-ignore: # 下列文件的变更不触发部署,可以自行添加 | ||
- README.md | ||
- LICENSE | ||
pull_request: | ||
branches: | ||
- main # 只在master上push触发部署 | ||
types: [closed] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [14.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
repo-token: ${{ secrets.DEPLOY_TOKEN }} | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
npm i | ||
- name: Build | ||
run: | | ||
npm run build | ||
cp README.md docs/.vuepress/dist/ | ||
cd docs/.vuepress/dist | ||
- name: Deploy | ||
uses: JamesIves/[email protected] | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN }} | ||
BRANCH: master # The branch the action should deploy to. | ||
FOLDER: docs/.vuepress/dist/ | ||
CLEAN: true |