Skip to content

CI/CD Pipeline

CI/CD Pipeline #63

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main ]
paths-ignore:
- README.md
- .gitignore
- TESTING.md
- readme-images/**
- testing-images/**
- .github/workflows/**
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install backend dependencies
run: |
cd backend
pip install -r requirements.txt
- name: Run backend tests
env:
SECRET_KEY: ${{ secrets.DJANGO_TEST_SECRET }}
run: |
cd backend
python manage.py test --settings=rabbit_rescue_REST.settings_test
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install frontend dependencies
run: |
cd frontend
npm install
- name: Run frontend unit/functional tests with Vitest
env:
VITE_STRIPE_LINK: ${{ secrets.VITE_STRIPE_LINK }}
run: |
cd frontend
npm run test
# - name: Start backend server for Cypress tests
# env:
# SECRET_KEY: ${{ secrets.DJANGO_TEST_SECRET }}
# DATABASE_URL: ${{ secrets.DATABASE_URL }}
# CLOUDINARY_URL: ${{ secrets.CLOUDINARY_URL }}
# FRONTEND_URL: ${{ secrets.FRONTEND_URL }}
# VITE_STRIPE_LINK: ${{ secrets.VITE_STRIPE_LINK }}
# run: |
# cd backend
# python manage.py collectstatic --noinput
# python manage.py runserver &
# - name: Run Cypress tests
# uses: cypress-io/github-action@v6
# with:
# browser: chrome
# start: npm start
# working-directory: frontend
deploy:
needs: test
# Only deploy when the push event is triggered on the main branch
# meaning that pull requests will not trigger a deployment
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy to Heroku (backend)
uses: akhileshns/heroku-deploy@v3.13.15 # This action deploys to Heroku
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: ${{secrets.HEROKU_BACKEND_NAME}}
heroku_email: ${{secrets.HEROKU_EMAIL}}
appdir: "backend"
dontautocreate: true
- name: Deploy to Heroku (frontend)
uses: akhileshns/heroku-deploy@v3.13.15 # This action deploys to Heroku
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: ${{secrets.HEROKU_FRONTEND_NAME}}
heroku_email: ${{secrets.HEROKU_EMAIL}}
appdir: "frontend"
dontautocreate: true