-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (46 loc) · 1.56 KB
/
deployment.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
name: Deployments
on:
workflow_dispatch:
workflow_call:
push:
branches:
- main
paths-ignore:
- ".github/**"
- ".vscode/**"
env:
MARIADB_ROOT_PASSWORD: ${{ secrets.MARIADB_ROOT_PASSWORD }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
ONISEP_EMAIL: ${{ secrets.ONISEP_EMAIL }}
ONISEP_PASSWORD: ${{ secrets.ONISEP_PASSWORD }}
ONISEP_APP_ID: ${{ secrets.ONISEP_APP_ID }}
jobs:
deploy-datatabse:
uses: ./.github/workflows/deploy_database_production.yml
secrets: inherit
deploy-api:
runs-on: self-hosted
needs: [deploy-datatabse]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Check if container exists
id: check-container
run: |
if docker ps -a | grep -q 'onisep-api'; then
echo "Container onisep api exists"
echo "::set-output name=container_exists::true"
else
echo "Container onisep api does not exist"
echo "::set-output name=container_exists::false"
fi
- name: Stop and Remove Old Container
if: steps.check-container.outputs.container_exists == 'true'
run: docker-compose stop onisep-api && docker-compose rm -f onisep-api
- name: Remove Old Image
if: steps.check-container.outputs.container_exists == 'true'
run: docker rmi elki_97413/onisep:latest
- name: Build Docker image and Start New Container
run: docker-compose up -d onisep-api