-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (53 loc) · 1.9 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
name: CI && CD
on:
push:
branches:
- main
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Set up Docker
uses: docker/setup-buildx-action@v2
- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install npm dependencies
run: npm ci
- name: Build and start Docker containers
run: |
docker-compose -f docker-compose.yml up -d --build
sleep 10 # Wait for containers to start
- name: Run database migrations
run: |
docker-compose exec -T app npx sequelize-cli db:drop
docker-compose exec -T app npx sequelize-cli db:create
docker-compose exec -T app npx sequelize-cli db:migrate
- name: Run unit tests
run: |
docker-compose exec -T app npm test
- name: Run integration tests
run: |
docker-compose exec -T app npm install cypress cypress-json-results
docker-compose exec -T app npx cypress run
- name: Notify on success
if: success()
run: |
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"🎉🎉🎉 Success! The CI & CD pipeline has completed without issues. All tests passed. :tada:"}' \
${{ secrets.SLACK_URL }}
- name: Notify on failure
if: failure()
run: |
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"🚨🚨🚨 Alert! The CI & CD pipeline has encountered problems and failed. Immediate review is required. :warning:"}' \
${{ secrets.SLACK_URL }}
- name: Shut down Docker containers
run: docker-compose down