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 gh-pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 22 | |
| - name: Install Git | |
| run: sudo apt-get install git -y | |
| - name: Switch to gh-pages branch | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git checkout -b gh-pages | |
| git merge main --allow-unrelated-histories -m "Merge from main branch" | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build project | |
| run: npm run build | |
| - name: Push to gh-pages | |
| run: | | |
| git add -A | |
| git commit -m "Deploy to gh-pages" || echo "No changes to commit" | |
| git pull --rebase origin gh-pages || echo "Nothing to rebase" | |
| git push origin gh-pages -f |