Skip to content

Merge pull request #60 from CSCE331-Fall2024/test/menuboard #51

Merge pull request #60 from CSCE331-Fall2024/test/menuboard

Merge pull request #60 from CSCE331-Fall2024/test/menuboard #51

Workflow file for this run

name: Deploy Backend to Heroku
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Checkout the repository with full history to avoid shallow clone issues
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch the entire history for Heroku
# Set up Node.js to install and build frontend
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22' # Adjust based on your Node.js version
# Install and build frontend, then move build to backend
- name: Build frontend
working-directory: ./frontend
run: |
npm install --legacy-peer-deps
CI=false npm run build
- name: Move frontend build to backend
run: |
rm -rf backend/build
mv frontend/build backend/
# Configure Git and deploy only the backend directory to Heroku
- name: Deploy Backend to Heroku
working-directory: ./backend
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
git init
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git checkout -b main # Create and switch to the main branch
git remote add heroku https://heroku:[email protected]/project-3-01-beastmode.git
git add .
git commit -m "Deploy backend directory" || echo "No changes to commit"
git push -f heroku main
# Clean up frontend build if deployment succeeded
- name: Cleanup frontend build
if: success()
run: rm -rf frontend/build
# Clean up backend build if deployment succeeded
- name: Cleanup backend build
if: success()
run: rm -rf backend/build
# Remove the .git directory in backend after deployment
- name: Cleanup .git directory in backend
working-directory: ./backend
run: |
rm -rf .git