-
Notifications
You must be signed in to change notification settings - Fork 1
110 lines (94 loc) · 2.88 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: CI/CD Pipeline
on:
push:
branches: [ main ]
paths-ignore:
- README.md
- .gitignore
- TESTING.md
- readme-images/**
- testing-images/**
- .github/workflows/**
pull_request:
branches: [ main ]
paths-ignore:
- README.md
- .gitignore
- TESTING.md
- readme-images/**
- testing-images/**
- .github/workflows/**
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