fix: 🐛 reorganize git identity configuration and streamline gh-pages … #5
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 Docs | |
| on: | |
| push: | |
| branches: ["main"] | |
| workflow_dispatch: {} | |
| # Branch-based Pages deployment via `docusaurus deploy` | |
| permissions: | |
| contents: write | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| # Required to push to gh-pages | |
| fetch-depth: 0 | |
| - name: Configure git identity | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - uses: pnpm/action-setup@v3 | |
| with: | |
| version: 10 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: "pnpm" | |
| - run: pnpm install --frozen-lockfile | |
| - name: Ensure gh-pages branch exists | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -e | |
| if git ls-remote --exit-code --heads origin gh-pages >/dev/null 2>&1; then | |
| echo "gh-pages branch exists" | |
| else | |
| echo "Initializing gh-pages branch" | |
| git switch --orphan gh-pages | |
| git rm -rf . || true | |
| echo '<!doctype html><meta charset="utf-8"><meta http-equiv="refresh" content="0; url=/docusaurus-plugins/">' > index.html | |
| git add index.html | |
| git commit -m "chore: initialize gh-pages" | |
| git push origin gh-pages | |
| git switch - | |
| fi | |
| - name: Deploy with Docusaurus | |
| env: | |
| GIT_USER: github-actions[bot] | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: pnpm --filter "@gracefullight/docusaurus-plugin-docs" run deploy |