Set up GitHub Actions workflow for GitHub Pages deployment - 3 #4
This file contains 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 # Trigger on push to main branch | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 # Latest version of checkout action | |
- name: Configure Git | |
run: | | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v4 # Latest version of gh-pages action | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} # Provided by GitHub | |
publish_dir: ./ # The directory to deploy | |
- name: Force Push to gh-pages | |
run: | | |
git push origin gh-pages --force | |
- name: Clean Git Repository | |
run: | | |
rm -rf .git/ | |
git init | |
git remote add origin https://github.com/rishabhjain1712/Portfolio.git | |
git fetch | |
git checkout -b gh-pages |