7
7
jobs :
8
8
test :
9
9
runs-on : ubuntu-latest
10
+ environment : testing
10
11
services :
11
12
postgres :
12
13
image : postgres:10.8
@@ -17,11 +18,12 @@ jobs:
17
18
ports :
18
19
- 5432:5432
19
20
steps :
20
- - uses : actions/checkout@v3
21
+ - uses : actions/checkout@v4
21
22
- name : Run unit tests
22
23
run : echo "Run unit tests"
23
24
build :
24
25
runs-on : ubuntu-latest
26
+ environment : staging
25
27
services :
26
28
postgres :
27
29
image : postgres:10.8
@@ -35,67 +37,13 @@ jobs:
35
37
strategy :
36
38
max-parallel : 1
37
39
steps :
38
- - uses : actions/checkout@v3
39
- - name : Setup CI/CD Server
40
+ - uses : actions/checkout@v4
41
+ - name : Build Docker image
40
42
run : |
41
- sudo apt-get update &&
42
- sudo apt-get install -y redis-server git &&
43
- sudo apt-get install -y cmake g++ gcc libjsoncpp-dev uuid-dev openssl &&
44
- sudo apt-get install -y libssl-dev zlib1g-dev libbz2-dev liblzma-dev &&
45
- sudo apt-get install -y postgresql postgresql-contrib &&
46
- sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/*
47
- - name : Install Drogon Framework
48
- run : |
49
- git clone https://github.com/drogonframework/drogon
50
- cd drogon &&
51
- git submodule update --init &&
52
- sudo mkdir build && cd build && sudo cmake .. && sudo make && sudo make install
53
- - name : Install JWT CPP Library
54
- run : |
55
- git clone https://github.com/Thalhammer/jwt-cpp.git
56
- cd jwt-cpp && mkdir build && cd build && sudo cmake .. && sudo make && sudo make install
57
- - name : Install Bcrypt CPP Library
58
- run : |
59
- git clone https://github.com/hilch/Bcrypt.cpp.git
60
- - name : Run Scripts
61
- run : |
62
- sudo chmod +x ./scripts/create_dot_env.sh
63
- ./scripts/create_dot_env.sh
64
- env :
65
- SECRET_KEY : ${{secrets.SECRET_KEY}}
66
- DB_NAME : ${{secrets.DB_NAME}}
67
- DB_USER : ${{secrets.DB_USER}}
68
- DB_PASS : ${{secrets.DB_PASS}}
69
- - name : Build
70
- run : |
71
- mkdir build && cd build && cmake .. && make
72
- - name : Compress binary
73
- run : |
74
- sudo mkdir drogon_user_service
75
- sudo cp .env drogon_user_service
76
- cd drogon_user_service && sudo zip -r drogon_user_service_stage.zip .
77
- - name : Upload compressed binary to S3
78
- # run: |
79
- # aws s3 cp drogon_user_service/drogon_user_service_stage.zip ${{ secrets.SMS_GATEWAY_S3_URI }}/drogon_user_service_stage.zip --region ${{ secrets.AWS_REGION }}
80
- run : echo "Upload to aws s3 here"
81
- env :
82
- AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
83
- AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
84
- deploy :
85
- runs-on : ubuntu-latest
86
- needs : build
87
- strategy :
88
- max-parallel : 1
89
- steps :
90
- - uses : actions/checkout@v3
91
- - name : Setup CI/CD Server
92
- run : |
93
- sudo apt-get update &&
94
- sudo apt-get install -y redis-server &&
95
- sudo apt-get install -y awscli
96
- - name : Deploy to stage
97
- # run: aws deploy create-deployment --region ${{ secrets.AWS_REGION }} --application-name sms-gateway --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name sms-gateway-server-2-dg --description "Github deployment for commit ${GITHUB_SHA}" --s3-location bucket=eneza-sms-gateway,key=sms-gateway-bundle-stage.zip,bundleType=zip
98
- run : echo "Create codedeploy deployment"
99
- env :
100
- AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
101
- AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
43
+ docker build \
44
+ --build-arg SECRET_KEY=${{ secrets.SECRET_KEY }} \
45
+ --build-arg DB_HOST=${{ secrets.DB_HOST }} \
46
+ --build-arg DB_NAME=${{ secrets.DB_NAME }} \
47
+ --build-arg DB_USER=${{ secrets.DB_USER }} \
48
+ --build-arg DB_PASSWORD=${{ secrets.DB_PASSWORD }} \
49
+ -t user_service:latest .
0 commit comments