Update README.md #3
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 React App to GitHub Pages | |
on: | |
push: | |
branches: | |
- main # Adjust if your default branch is different (e.g., "master") | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
build_dir: ${{ steps.upload-build.outputs.build_dir }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' # Adjust the Node.js version as needed | |
- name: Install dependencies | |
run: npm install | |
- name: Build React app | |
run: npm run build | |
- name: Upload build files | |
id: upload-build | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build | |
path: ./build # Adjust this path if your build output directory is different | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build # Ensures the deploy job only runs after a successful build | |
steps: | |
- name: Download build files | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: ./build | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./build |