-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (111 loc) · 3.44 KB
/
pipeline.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
111
112
113
114
115
name: Deployment Pipeline
on:
push:
branches:
- main
- dev
- workflow-testing
pull_request:
branches: [main]
types: [opened, synchronize]
jobs:
test_lint_backend:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: create .env file
run: |
touch .env
echo DEV_MONGODB_URI=${{ secrets.DEV_MONGODB_URI }} >> .env
echo CLOUDINARY_NAME=${{ secrets.CLOUDINARY_NAME }} >> .env
echo CLOUDINARY_API_KEY=${{ secrets.CLOUDINARY_API_KEY }} >> .env
echo CLOUDINARY_API_SECRET=${{ secrets.CLOUDINARY_API_SECRET }} >> .env
- name: npm install
run: npm install
- name: lint
run: npm run lint
- name: test
run: npm test
test_lint_frontend:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: npm install
run: npm install
- name: lint
run: npm run lint
- name: test
run: npm test
- name: install backend dependencies, create .env (for cypress to run)
run: |
cd ../backend
touch .env
echo DEV_MONGODB_URI=${{ secrets.DEV_MONGODB_URI }} >> .env
echo CLOUDINARY_NAME=${{ secrets.CLOUDINARY_NAME }} >> .env
echo CLOUDINARY_API_KEY=${{ secrets.CLOUDINARY_API_KEY }} >> .env
echo CLOUDINARY_API_SECRET=${{ secrets.CLOUDINARY_API_SECRET }} >> .env
npm install
- name: cypress tests
uses: cypress-io/github-action@v2
with:
start: npm run server:dev, npm start
wait-on: 'http://localhost:3001/health, http://localhost:3000'
working-directory: ./frontend
build:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: backend
needs: [test_lint_backend, test_lint_frontend]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: npm install
run: npm install
- name: install frontend dependencies
run: cd ../frontend && npm install
- name: build ui
run: npm run build:ui
deploy:
if: ${{ github.ref == 'refs/head/main' }}
runs-on: ubuntu-20.04
needs: [build]
steps:
- uses: actions/checkout@v2
- uses: akhileshns/[email protected]
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "instaclone-sc"
heroku_email: "[email protected]"
appdir: "backend"
healthcheck: ""
checkstring: "ok"
rollbackonhealthcheckfailed: true
tag_release:
if: ${{ github.ref == 'refs/head/main' }}
needs: [deploy]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: Bump version and push tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# for deploying, make sure to have all final dependencies installed before deploying at all. aka, don't deploy, realize you need a new dep and then deploy again
# todo: research how i can add new packages after deployment and then redeploy