fix: actions node 422报错 #40
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 Site to Github Pages | |
| on: | |
| push: | |
| branches: ["main"] | |
| workflow_dispatch: | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@main | |
| - name: Detect package manager | |
| id: detect-package-manager | |
| run: | | |
| if [ -f "${{ github.workspace }}/package.json" ]; then | |
| echo "manager=npm" >> $GITHUB_OUTPUT | |
| echo "command=ci" >> $GITHUB_OUTPUT | |
| echo "runner=npx --no-install" >> $GITHUB_OUTPUT | |
| exit 0 | |
| else | |
| echo "Unable to determine package manager" | |
| exit 1 | |
| fi | |
| - name: Cache pnpm modules | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: cache-pnpm-modules | |
| with: | |
| path: ~/.pnpm-store | |
| key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/package.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}- | |
| - uses: pnpm/action-setup@v2.0.1 | |
| with: | |
| version: latest | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: | | |
| pnpm install | |
| - name: Build | |
| run: | | |
| pnpm run build | |
| touch ./out/.nojekyll | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./out | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Publish to GitHub Pages 🚀 | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| # uses: JamesIves/github-pages-deploy-action@v4 | |
| # with: | |
| # token: ${{ secrets.ACCESS_TOKEN }} | |
| # branch: gh-pages # The branch the action should deploy to. | |
| # folder: build # The folder the action should deploy. |