update #1
Workflow file for this run
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: | |
- master # Run this action on pushes to the master branch | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' # Use the correct version for your project | |
- name: Install dependencies | |
run: npm install | |
- name: Build project | |
run: npm run build | |
- name: Deploy to GitHub Pages | |
run: | | |
# Configure Git | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email 'actions@github.com' | |
# Clone the repository and switch to gh-pages branch | |
git clone https://github.com/${{ github.repository }} deploy-repo | |
cd deploy-repo | |
git checkout -B gh-pages | |
# Remove existing files and copy new build files | |
rm -rf * | |
cp -r ../build/* . | |
# Commit and push changes | |
git add . | |
git commit -m "Deploy website from master" | |
git push origin gh-pages | |