change workflow #12
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
name: Pages | |
# 触发器、分支 | |
on: | |
push: | |
branches: | |
- gh-pages # default branch | |
jobs: | |
build: | |
runs-on: ubuntu-latest # 定运行所需要的虚拟机环境 | |
permissions: | |
contents: write | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# 每个name表示一个步骤:step | |
- name: Use Node.js 20.12.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.12.2' | |
# 缓存依赖项: https://docs.github.com/cn/actions/using-workflows/caching-dependencies-to-speed-up-workflows | |
- name: Cache NPM dependencies | |
uses: actions/cache@v4 | |
id: cache | |
with: | |
path: node_modules | |
key: ${{ runner.OS }}-npm-cache | |
restore-keys: | | |
${{ runner.OS }}-npm-cache | |
- name: Install Dependencies | |
if: steps.cache.outputs.cache-hit != 'true' # 如果没有缓存 node_modules | |
run: npm install | |
- name: Deploy | |
id: deploy | |
uses: sma11black/hexo-action@v1.0.3 | |
with: | |
deploy_key: ${{ secrets.HEXO_DEPLOY_KEY }} | |
user_name: Xsyin | |
user_email: shouyinxu@163.com | |
commit_msg: ${{ github.event.head_commit.message }}ion) | |
- name: Get the output | |
run: | | |
echo "${{ steps.deploy.outputs.notify }}" | |
sync: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Sync to Gitee | |
uses: wearerequired/git-mirror-action@master | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.HEXO_DEPLOY_KEY }} | |
with: | |
# 源仓库 | |
source-repo: git@github.com:Xsyin/Xsyin.github.io.git | |
# 目标仓库 | |
destination-repo: git@gitee.com:xsyin/blog.git | |
reload-pages: | |
needs: sync | |
runs-on: ubuntu-latest | |
steps: | |
- name: Build Gitee Pages | |
uses: yanglbme/gitee-pages-action@main | |
with: | |
gitee-username: xsyin | |
gitee-password: ${{ secrets.GITEE_PASSWORD }} | |
gitee-repo: xsyin/blog | |
branch: master |