-
Notifications
You must be signed in to change notification settings - Fork 1
154 lines (133 loc) · 6.47 KB
/
release-billing-server.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: 🚀release-billing-server
run-name: 🚀release-billing-server-${{ github.event.inputs.build_type}}@${{ github.ref_name }}
on:
workflow_dispatch:
inputs:
build_type:
type: choice
description: Select the type of build
options:
- dev
- prod
jobs:
input-validation:
runs-on: ubuntu-latest
steps:
- id: input-validation
name: input validation
run: |
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
build_type=${{ github.event.inputs.build_type }}
if [ "$build_type" = "dev" ]; then
echo "build_type is dev"
elif [ "$build_type" = "prod" ]; then
echo "build_type is prod"
else
echo -e "${RED}build_type is not valid${NC}"
exit 1
fi
build-billing-server:
runs-on: ubuntu-latest
needs: input-validation
steps:
- name: docker init
run: docker system prune --volumes -a -f
- name: Checkout
uses: actions/checkout@v3
- name: DEV Configure AWS credentials
if: github.event.inputs.build_type == 'dev'
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_DEV_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_DEV_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: PROD Configure AWS credentials
if: github.event.inputs.build_type == 'prod'
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_PROD_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_PROD_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR Private
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
context: .
tags: ${{ steps.login-ecr.outputs.registry }}/${{ github.event.inputs.build_type }}-billing-server:latest
platforms: linux/x86_64
target: billing-server
file: dockerfile.billing
release-billing-server:
runs-on: ${{ github.event.inputs.build_type }}-billing-server
needs: [input-validation, build-billing-server]
# needs: [input-validation]
steps:
- name: Checkout
uses: Bhacaz/checkout-files@v2
with:
files: docker-compose-billing.yml
- name: DEV Configure AWS credentials
if: github.event.inputs.build_type == 'dev'
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_DEV_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_DEV_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: PROD Configure AWS credentials
if: github.event.inputs.build_type == 'prod'
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_PROD_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_PROD_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR Private
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: docker init
run: docker system prune --volumes -a -f
- name: DEV set .env
if: github.event.inputs.build_type== 'dev'
run: |
sed -i "s|DOGU_BILLING_RUN_TYPE=.*$|DOGU_BILLING_RUN_TYPE=development|" ./docker-compose-billing.yml
sed -i "s|DOGU_BILLING_DB_URL=.*$|DOGU_BILLING_DB_URL=${{secrets.DEV_DOGU_BILLING_DB_URL }}|" ./docker-compose-billing.yml
sed -i "s|DOGU_BILLING_DB_SSL_CONNECTION=.*$|DOGU_BILLING_DB_SSL_CONNECTION=${{secrets.DEV_DOGU_BILLING_DB_SSL_CONNECTION }}|" ./docker-compose-billing.yml
sed -i "s|DOGU_CONSOLE_DB_READ_URL=.*$|DOGU_CONSOLE_DB_READ_URL=${{secrets.DEV_DOGU_CONSOLE_DB_READ_URL }}|" ./docker-compose-billing.yml
sed -i "s|DOGU_BILLING_NICE_CLIENT_KEY=.*$|DOGU_BILLING_NICE_CLIENT_KEY=${{secrets.DEV_DOGU_BILLING_NICE_CLIENT_KEY }}|" ./docker-compose-billing.yml
sed -i "s|DOGU_BILLING_NICE_SECRET_KEY=.*$|DOGU_BILLING_NICE_SECRET_KEY=${{secrets.DEV_DOGU_BILLING_NICE_SECRET_KEY }}|" ./docker-compose-billing.yml
sed -i "s|DOGU_EMAIL_ID=.*$|DOGU_EMAIL_ID=${{secrets.DOGU_EMAIL_ID }}|" ./docker-compose-billing.yml
sed -i "s|DOGU_EMAIL_PW=.*$|DOGU_EMAIL_PW=${{secrets.DOGU_EMAIL_PW }}|" ./docker-compose-billing.yml
- name: PROD set .env
if: github.event.inputs.build_type == 'prod'
run: |
sed -i "s|DOGU_BILLING_RUN_TYPE=.*$|DOGU_BILLING_RUN_TYPE=production|" ./docker-compose-billing.yml
sed -i "s|DOGU_BILLING_DB_URL=.*$|DOGU_BILLING_DB_URL=${{secrets.PROD_DOGU_BILLING_DB_URL }}|" ./docker-compose-billing.yml
sed -i "s|DOGU_BILLING_DB_SSL_CONNECTION=.*$|DOGU_BILLING_DB_SSL_CONNECTION=${{secrets.PROD_DOGU_BILLING_DB_SSL_CONNECTION }}|" ./docker-compose-billing.yml
sed -i "s|DOGU_CONSOLE_DB_READ_URL=.*$|DOGU_CONSOLE_DB_READ_URL=${{secrets.PROD_DOGU_CONSOLE_DB_READ_URL }}|" ./docker-compose-billing.yml
sed -i "s|DOGU_BILLING_NICE_CLIENT_KEY=.*$|DOGU_BILLING_NICE_CLIENT_KEY=${{secrets.PROD_DOGU_BILLING_NICE_CLIENT_KEY }}|" ./docker-compose-billing.yml
sed -i "s|DOGU_BILLING_NICE_SECRET_KEY=.*$|DOGU_BILLING_NICE_SECRET_KEY=${{secrets.PROD_DOGU_BILLING_NICE_SECRET_KEY }}|" ./docker-compose-billing.yml
sed -i "s|DOGU_EMAIL_ID=.*$|DOGU_EMAIL_ID=${{secrets.DOGU_EMAIL_ID }}|" ./docker-compose-billing.yml
sed -i "s|DOGU_EMAIL_PW=.*$|DOGU_EMAIL_PW=${{secrets.DOGU_EMAIL_PW }}|" ./docker-compose-billing.yml
- name: run
run: |
docker ps -qa | xargs -r docker rm -f
docker compose -f docker-compose-billing.yml pull ${{ github.event.inputs.build_type }}-billing-server
docker compose -f ./docker-compose-billing.yml --verbose up -d ${{ github.event.inputs.build_type }}-billing-server
send-slack:
runs-on: ubuntu-latest
needs: release-billing-server
if: ${{ always() }}
steps:
- name: Send Slack
uses: dogu-team/[email protected]
with:
template: 'CD'
slack-channel-id: 'C057ML9UH34'
result-status: ${{ needs.release-billing-server.result }}
ignore-notify: false
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}