-
Notifications
You must be signed in to change notification settings - Fork 7
90 lines (78 loc) · 3.04 KB
/
main.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
name: Deploy to Amazon LightSail
on:
workflow_dispatch:
push:
branches:
- main
# 본인이 설정한 값을 여기서 채워넣습니다.
# 리전, 버킷 이름, CodeDeploy 앱 이름, CodeDeploy 배포 그룹 이름
env:
AWS_REGION: ap-northeast-2
S3_BUCKET_NAME: 42library.kr
CODE_DEPLOY_APPLICATION_NAME: newjiphyeonjeon
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: deploy
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
environment: production
steps:
# (1) 기본 체크아웃
- name: Checkout
uses: actions/checkout@v3
- name: setup node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: setup pnpm
run: |
corepack enable
corepack prepare pnpm@latest-8 --activate
pnpm config set store-dir .pnpm-store
- name: install dependencies
working-directory: backend
run: pnpm install
# TODO(@scarf005): #594
# - name: build backend
# working-directory: backend
# run: pnpm build
- name: create .env file
run: |
echo "MYSQL_ROOT_PASSWORD=${{ secrets.MYSQL_ROOT_PASSWORD }}
MYSQL_DATABASE=${{ secrets.MYSQL_DATABASE }}
MYSQL_USER=${{ secrets.MYSQL_USER }}
MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }}
BACKUP_USER=${{ secrets.BACKUP_USER}}
BACKUP_PASSWORD=${{ secrets.BACKUP_PASSWORD }}
ADMIN_SLACK_ID=${{ secrets.ADMIN_SLACK_ID }}
DB_SCHEMA=${{ secrets.DB_SCHEMA }}
MODE=${{ secrets.MODE }}
NODE_ENV=${{ secrets.NODE_ENV }}
CLIENT_ID=${{ secrets.CLIENT_ID }}
CLIENT_SECRET=${{ secrets.CLIENT_SECRET }}
REDIRECT_URL=${{ secrets.REDIRECT_URL }}
CLIENT_URL=${{ secrets.CLIENT_URL }}
BOT_USER_OAUTH_ACCESS_TOKEN=${{ secrets.BOT_USER_OAUTH_ACCESS_TOKEN }}
JWT_SECRET=${{ secrets.JWT_SECRET }}
NAVER_BOOK_SEARCH_CLIENT_ID=${{ secrets.NAVER_BOOK_SEARCH_CLIENT_ID }}
NATION_LIBRARY_KEY=${{ secrets.NATION_LIBRARY_KEY }}
NAVER_BOOK_SEARCH_SECRET=${{ secrets.NAVER_BOOK_SEARCH_SECRET }}" > .env
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Upload to AWS S3
run: |
aws deploy push \
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--s3-location s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip \
--source .
- name: Deploy to AWS LightSail from S3
run: |
aws deploy create-deployment \
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \
--s3-location bucket=$S3_BUCKET_NAME,key=$GITHUB_SHA.zip,bundleType=zip