Fix GitHub Actions workflow permissions for deployment #4
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
# .github/workflows/deploy.yml | |
name: Build and Deploy Yew App to GitHub Pages | |
on: | |
push: | |
branches: | |
- main # 当 main 分支有推送时触发 | |
permissions: | |
contents: write # 赋予对仓库内容的写权限 | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. 检出仓库代码 | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# 2. 设置 Rust 工具链 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
target: wasm32-unknown-unknown | |
override: true | |
# 3. 安装 wasm-pack | |
- name: Install wasm-pack | |
run: cargo install wasm-pack | |
# 4. 安装 cargo-make | |
- name: Install cargo-make | |
run: cargo install cargo-make | |
# 5. 构建项目 | |
- name: Build project | |
run: cargo make build-ci | |
# 6. 列出 static 目录内容(用于调试) | |
- name: List static directory | |
run: ls -la ./static | |
# 7. 部署到 GitHub Pages | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./static | |
publish_branch: gh-pages | |
force_orphan: true | |
allow_empty_commit: true |