-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (90 loc) · 3.93 KB
/
server_ci_for_alpha.yaml
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
# This is a basic workflow to help you get started with Actions
name: SERVER-CI-FOR-ALPHA
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [alpha]
# pull_request:
# branches: [alpha]
# Allows you to run this workflow manually from the Actions tab
# workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build_and_deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Build
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x ./common_api_server/gradlew
- name: Clean for build with Gradle
run: |
cd ./common_api_server
./gradlew clean
- name: Build with Gradle
run: |
cd ./common_api_server
./gradlew bootJar
# Build and push docker image to ECR
- name: Setup AWS with credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.OURAPT_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.OURAPT_AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Generate deployment package
run: |
cd ./common_api_server
mkdir ./deploy
cp ./build/libs/*.jar ./deploy
echo "web: ls -al && java --show-version -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar ourapt-0.0.1-SNAPSHOT.jar" > ./deploy/Procfile
- name: Deploy to EB
env:
SPRING_PROFILE_ACTIVE: alpha
RDB_HOST: ${{ secrets.RDB_HOST_ALPHA }}
RDB_USERNAME: ${{ secrets.RDB_USERNAME_ALPHA }}
RDB_PASSWORD: ${{ secrets.RDB_PASSWORD_ALPHA }}
KARROT_APP_ID: ${{ secrets.KARROT_APP_ID_ALPHA }}
KARROT_APP_SECRET: ${{ secrets.KARROT_APP_SECRET_ALPHA }}
KARROT_API_KEY: ${{ secrets.KARROT_API_KEY_ALPHA }}
KARROT_OPEN_API_BASE_URL: https://openapi.alpha.kr.karrotmarket.com
KARROT_O_API_BASE_URL: https://oapi.alpha.kr.karrotmarket.com
run: |
echo "Installing EB - CLI..."
cd ./common_api_server/deploy
python -m pip install --upgrade pip
pip install awsebcli --upgrade
eb --version
echo "Initializing EB..."
eb init --region ap-northeast-2 --platform "Corretto 11 running on 64bit Amazon Linux 2" ourapt-api
eb use ourapt-api-alpha
echo "Setting environment variables..."
eb setenv \
SPRING_PROFILE_ACTIVE=${{ env.SPRING_PROFILE_ACTIVE }} \
RDB_HOST=${{ env.RDB_HOST }} \
RDB_USERNAME=${{ env.RDB_USERNAME }} \
RDB_PASSWORD=${{ env.RDB_PASSWORD }} \
KARROT_APP_ID=${{ env.KARROT_APP_ID }} \
KARROT_APP_SECRET=${{ env.KARROT_APP_SECRET }} \
KARROT_API_KEY=${{ env.KARROT_API_KEY }} \
KARROT_OPEN_API_BASE_URL=${{ env.KARROT_OPEN_API_BASE_URL }} \
KARROT_O_API_BASE_URL=${{ env.KARROT_O_API_BASE_URL }}
echo "Start to deploy to EB..."
eb deploy
- name: Send slack webhook
run: |
curl --location --request POST 'https://hooks.slack.com/services/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' \
--header 'Authorization: Bearer Vp7VDNuVl4w1-nrU1oDgVSQnHI4' \
--header 'Content-Type: text/plain' \
--data-raw '{"text": "[Alpha] Success to deploy alpha server"}'