-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (49 loc) · 1.3 KB
/
cicd.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
name: CI / CD
on:
push:
paths:
- "api/**"
- ".github/workflows/cicd.yml"
workflow_dispatch:
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and run tests
run: docker compose up --build --exit-code-from test test
- name: Clean up
run: docker compose down
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build-and-test
if: github.ref == 'refs/heads/develop'
steps:
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEV_HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd amazonia-360
git pull --rebase
sudo docker compose down
sudo docker compose up -d api --build
health-check:
name: Health Check
runs-on: ubuntu-latest
needs: deploy
if: github.ref == 'refs/heads/develop'
steps:
- name: URL Health Check
uses: Jtalk/url-health-check-action@v4
with:
url: ${{ secrets.DEV_HEALTHCHECK }}
retries: 5
wait: 10