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
# .github/workflows/deploy.yml | |
name: Deploy React App to GitHub Pages | |
on: | |
push: | |
branches: | |
- main # Trigger deployment on push to main branch | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# 2. Setup Node.js environment | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16" # Specify Node.js version | |
# 3. Install project dependencies | |
- name: Install dependencies | |
run: npm install | |
# 4. Build the React app | |
- name: Build React app | |
run: npm run build | |
# 5. Deploy to GitHub Pages using PAT and git commands | |
- name: Deploy to GitHub Pages | |
env: | |
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }} | |
run: | | |
git config --global user.name "jonhealy1" | |
git config --global user.email "[email protected]" | |
git remote add deploy https://jonhealy1:${DEPLOY_TOKEN}@github.com/stacchain/stacchain.github.io.git | |
git fetch deploy | |
git checkout deploy/main || git checkout --orphan deploy/main | |
git rm -rf . | |
cp -R build/* . | |
git add . | |
git commit -m "Deploy React app to GitHub Pages [skip ci]" | |
git push deploy deploy/main --force |