-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (98 loc) · 3.82 KB
/
deploy.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
name: soup
on:
push:
branches:
- production
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 🗃️ Checkout
uses: actions/checkout@v2
with:
submodules: recursive
token: ${{ secrets.CLIENT_REPO_ACCESS_TOKEN }}
- name: 📦️ Setup JDK 11.0.12
uses: actions/setup-java@v1
with:
java-version: 11.0.12
- name: 💾 Cache Gradle & Spring
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: 🔧 Build Spring server
working-directory: ./SouP
run: |
chmod +x ./gradlew
./gradlew clean build
- name: 📦️ Setup NodeJS 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: 💾 Cache NPM & Next.js
uses: actions/cache@v3
with:
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
path: |
~/.npm
${{ github.workspace }}/soup-frontend/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('soup-frontend/**/package-lock.json') }}-${{ hashFiles('soup-frontend/**.[jt]s', 'soup-frontend/**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('soup-frontend/**/package-lock.json') }}-
- name: 📦️ Install NPM modules for Next.js client
working-directory: ./soup-frontend
run: |
npm i
- name: 🔧 Build Next.js client
working-directory: ./soup-frontend
run: |
npx next build
- name: 📂 Make server zip file
run: |
mkdir pre-deploy
cp -r deploy/server/. pre-deploy/
cp SouP/build/libs/*.jar pre-deploy/
zip -r deploy/soup-server.zip pre-deploy
rm -rf pre-deploy
- name: 📂 Make client zip file
run: |
mkdir pre-deploy
cp -r deploy/client/. pre-deploy/
cp -r soup-frontend/.next/standalone/. pre-deploy
cp -r soup-frontend/public pre-deploy/public
cp -r soup-frontend/.next/static pre-deploy/.next/static
zip -r deploy/soup-client.zip pre-deploy
rm -rf pre-deploy
- name: 🚚 Upload to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
cd deploy
aws s3 cp --region ap-northeast-2 --acl private ./soup-server.zip s3://soup-build4/
aws s3 cp --region ap-northeast-2 --acl private ./soup-client.zip s3://soup-build4/
- name: 🚀 Deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws deploy create-deployment \
--application-name soup \
--deployment-group-name soup-client \
--file-exists-behavior OVERWRITE \
--s3-location bucket=soup-build4,bundleType=zip,key=soup-client.zip \
--region ap-northeast-2
aws deploy create-deployment \
--application-name soup \
--deployment-group-name soup-server \
--file-exists-behavior OVERWRITE \
--s3-location bucket=soup-build4,bundleType=zip,key=soup-server.zip \
--region ap-northeast-2