gs_index: v5 #24
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: Build and Deploy to GitHub Pages | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- 'src/backend/gs_index/**' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout master branch | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: | | |
cd src/backend/gs_index | |
npm install | |
- name: Build the project | |
run: | | |
cd src/backend/gs_index | |
npm run build | |
- name: List build directory contents | |
run: | | |
cd src/backend/gs_index/dist | |
ls -la | |
- name: Deploy to GitHub Pages | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: success() | |
run: | | |
# Configure git | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
# Clone the gh-pages branch | |
git clone --branch=gh-pages https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages | |
cd gh-pages | |
# Copy the built files to the gh-pages branch | |
cp -r ../src/backend/gs_index/dist/index.html ./ | |
cp -r ../src/backend/gs_index/dist/favicon.ico ./ | |
rm -rf ./static/* | |
cp -r ../src/backend/gs_index/dist/GlossySnake/static/* ./static/ | |
# Commit and push the changes | |
git add . | |
git commit -m "Update GitHub Pages with the latest build from master" | |
git push origin gh-pages |