forked from mbuchoff/hackathon_backend_230909
-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (50 loc) · 1.44 KB
/
Copy pathci-cd.yml
File metadata and controls
53 lines (50 loc) · 1.44 KB
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
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:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: develop
- 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: Checkout Code
uses: actions/checkout@v3
with:
ref: develop
- name: Deploying Application with rsync over SSH to EC2
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.SSH_EC2_IP }}
REMOTE_USER: ${{ secrets.SSH_EC2_USER }}
SOURCE: .
TARGET: ${{ github.event.repository.name }}
SCRIPT_AFTER: |
cd ~
cd ${{ github.event.repository.name }}
docker compose up -d --build