Trigger Pages source configuration #7
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: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| pages: write | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build and export | |
| run: npm run predeploy | |
| - name: Deploy to gh-pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| # Optional: set GH_PAGES_PAT secret with a Personal Access Token (repo:public_repo or repo scope) if GITHUB_TOKEN cannot push | |
| personal_token: ${{ secrets.GH_PAGES_PAT }} | |
| publish_dir: ./out | |
| publish_branch: gh-pages | |
| - name: Ensure Pages site is configured to use gh-pages | |
| env: | |
| REPO: ${{ github.repository }} | |
| OWNER: ${{ github.repository_owner }} | |
| run: | | |
| echo "Setting Pages source to gh-pages branch..." | |
| curl -s -X PUT -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github+json" \ | |
| https://api.github.com/repos/$REPO/pages -d '{"source":{"branch":"gh-pages","path":"/"}}' | jq -r '.html_url' || true | |