-
Notifications
You must be signed in to change notification settings - Fork 1
44 lines (41 loc) · 1.18 KB
/
ci-cd.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
name: Build, Test and Deploy backend
on:
# opening a pull request to master and develop branch will be a trigger
pull_request:
branches:
- develop
# any code pushed to master and develop branch will also be a trigger
push:
branches:
- develop
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Injecting environment vars
run: |
echo "${{ secrets.TEST_SECRETS }}" >> .env
- name: Building Docker containers
run: |
docker-compose up -d --build
docker-compose logs
# - name: Running Tests inside Docker containers
# run: |
# docker-compose exec -T api pytest
deploy:
name: Deploying on EC2 via SSH
if: ${{ github.event_name == 'push' }}
needs: [build-test]
runs-on: ubuntu-latest
steps:
- name: Deploying Application on EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_EC2_IP }}
username: ${{ secrets.SSH_EC2_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
script: |
cd ~/.scripts
./docker-ec2-deploy.sh