-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (72 loc) · 2.77 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
name: dear Web Admin
on:
push:
branches: "main"
env:
S3_BUCKET_NAME: dear-web
CODE_DEPLOY_APPLICATION_NAME: dear-web
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: dear-web-group
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: yarn install
- name: Build Next.js application
run: yarn run build
# - uses: actions/setup-node@v3
# with:
# node-version: ${{ matrix.node-version }}
# cache: "yarn"
- name: Make config directory and create config.json
run: |
mkdir -p ./src/config
echo "${{ secrets.CONFIG }}" > ./src/config/config.json
- name: Deploy with SSH
if: github.ref == 'refs/heads/main'
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }} # EC2 인스턴스 퍼블릭 DNS 또는 퍼블릭 IP
username: ec2-user
key: ${{ secrets.PRIVATE_KEY }} # pem 키
port: ${{ secrets.PORT }}
script: |
cd /path/to/your/app
git pull origin main
yarn install
yarn run build
sudo systemctl restart nginx
# - name: Create config directory and config.json
# run: |
# mkdir -p ./src/config
# echo "{\"server\": \"${{ secrets.CONFIG_JSON }}\"}" > ./src/config/config.json
# # 프로젝트 빌드
# - name: Build next app
# run: yarn build
# # 프로젝트 압축
# - name: Make zip file
# run: zip -qq -r ./chagok.zip . -x "node_modules/*"
# # AWS 자격 증명 설정
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v2
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ap-northeast-2
# # 압축된 파일을 S3에 업로드
# - name: Upload to S3
# run: aws s3 cp --region ap-northeast-2 ./chagok.zip s3://$S3_BUCKET_NAME/chagok.zip
# # S3에 업로드된 빌드 파일을 이용해 CodeDeploy가 정의된 동작을 하도록 트리거
# - name: Code Deploy
# 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,bundleType=zip,key=chagok.zip