Skip to content

fix: ensure log directory is created if it does not exist before writ… #23

fix: ensure log directory is created if it does not exist before writ…

fix: ensure log directory is created if it does not exist before writ… #23

Workflow file for this run

name: Build and Deploy
on:
push:
branches:
- gh-pages
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20' # 根据你的项目需求设置 Node.js 版本
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 9 # 你可以指定具体的 pnpm 版本
- name: Install dependencies
run: pnpm install # 使用 pnpm 安装依赖
- name: Build project
run: pnpm play:build # 运行构建脚本
- name: Configure SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: Remove assets folder from target repository
run: |
git clone [email protected]:chensuifengran/chensuifengran.github.io.git target-repo
cd target-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git fetch
git checkout main
rm -rf assets # 删除 assets 文件夹
git add .
git commit -m "Remove assets folder" || true
git push origin main
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} # PERSONAL_ACCESS_TOKEN
publish_dir: ./dist # 指定要发布的目录
external_repository: chensuifengran/chensuifengran.github.io # 替换为你的目标仓库地址
publish_branch: main # 发布的目标分支
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'