Merge branch 'docusaurus-version' into docusaurus-version #16
This file contains hidden or 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: Deploy to GitHub Pages | |
on: | |
pull_request: | |
branches: [docusaurus-version] | |
push: | |
branches: [docusaurus-version] | |
env: | |
NODE_OPTIONS: --max_old_space_size=8192 | |
permissions: | |
contents: read | |
statuses: write | |
jobs: | |
test-deploy: | |
if: github.event_name != 'push' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
cache: yarn | |
# ==== 新增:观测与加 swap(放在安装依赖前) ==== | |
- name: Show runner memory | |
run: node -v && free -h && df -h | |
- name: Add swap (8G) | |
run: | | |
sudo fallocate -l 8G /swapfile | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
free -h | |
# ==== 新增结束 ==== | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Test build website | |
run: yarn docusaurus build | |
- name: Report status to PR | |
if: always() | |
continue-on-error: true | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { owner, repo } = context.repo; | |
const success = '${{ job.status }}' === 'success'; | |
const sha = context.payload.pull_request?.head?.sha || context.sha; | |
const statusContext = 'Test deployment (required)'; | |
try { | |
await github.rest.repos.createCommitStatus({ | |
owner, | |
repo, | |
sha, | |
state: success ? 'success' : 'failure', | |
target_url: `https://github.com/${owner}/${repo}/actions/runs/${{ github.run_id }}`, | |
description: success ? '✅ Build succeeded' : '❌ Build failed', | |
context: statusContext | |
}); | |
core.info(`Status reported on ${sha}: ${statusContext} = ${success ? 'success' : 'failure'}`); | |
} catch (error) { | |
core.warning('Failed to report status: ' + error.message); | |
} | |
deploy: | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
cache: yarn | |
- name: Show runner memory | |
run: node -v && free -h && df -h | |
- name: Add swap (8G) | |
run: | | |
sudo fallocate -l 8G /swapfile | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
free -h | |
- uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.GH_PAGES_DEPLOY }} | |
- name: Deploy to GitHub Pages | |
env: | |
USE_SSH: true | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "MatthewJeffson" | |
yarn install --frozen-lockfile | |
yarn deploy |