chore: auto deploy GitHub & Gitee Pages #29
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: Build and deploy | |
on: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
docs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Cache node modules | |
uses: actions/cache@v2 | |
id: cache | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: npm install | |
- name: Build VuePress site | |
run: yarn docs:build | |
- name: Deploy to GitHub Pages | |
uses: crazy-max/ghaction-github-pages@v2 | |
with: | |
target_branch: gh-pages | |
build_dir: docs/.vuepress/dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build: | |
runs-on: ubuntu-latest | |
if: github.repository == 'doocs/jvm' | |
needs: docs | |
steps: | |
- name: Sync to Gitee | |
uses: wearerequired/git-mirror-action@master | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }} | |
with: | |
source-repo: git@github.com:doocs/jvm.git | |
destination-repo: git@gitee.com:Doocs/jvm.git | |
- name: Build Gitee Pages | |
uses: yanglbme/gitee-pages-action@main | |
with: | |
gitee-username: yanglbme | |
gitee-password: ${{ secrets.GITEE_PASSWORD }} | |
gitee-repo: doocs/jvm | |
branch: gh-pages |