Repository navigation
chore: change workflow #3
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: Build and Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' # 选择合适的 Node 版本 | |
| - name: Install dependencies | |
| working-directory: web | |
| run: npm install | |
| - name: Compile TypeScript | |
| working-directory: web | |
| run: npm run build | |
| - name: Install Pandoc | |
| uses: pandoc/actions/setup@v1 # 安装最新 Pandoc;可以指定 version: 'latest' 或具体版本如 '3.1.1' | |
| - name: Create assets directory if not exists | |
| run: mkdir -p web/assets | |
| - name: Convert README.md to en-us.html | |
| run: pandoc README.md -t html -o web/assets/en-us.html | |
| - name: Convert README-zh-cn.md to zh-cn.html | |
| run: pandoc README-zh-cn.md -t html -o web/assets/zh-cn.html | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| # Upload entire repository | |
| path: ./web | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build # 依赖 build 作业 | |
| environment: | |
| name: github-pages # Pages 环境 | |
| url: ${{ steps.deployment.outputs.page_url }} # 可选:输出 URL | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 # 使用 v4 部署 |