-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (104 loc) · 3.48 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
114
115
116
name: MarketNawaFE
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20.x'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Install AWS CLI
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update
- 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: Generate deployment package
run: |
mkdir -p .ebextensions
cat <<EOF > .ebextensions/00-makeFiles.config
files:
"/etc/nginx/conf.d/vueapp.conf":
mode: "000755"
owner: root
group: root
content: |
server {
listen 80;
server_name _;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;
proxy_cache_bypass \$http_upgrade;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
EOF
cat <<EOF > Procfile
web: node server.js
EOF
mkdir -p .platform/nginx/conf.d
cat <<EOF > .platform/nginx/conf.d/proxy.conf
server {
listen 80;
server_name _;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;
proxy_cache_bypass \$http_upgrade;
}
}
EOF
cat <<EOF > .platform/nginx/conf.d/health.conf
server {
listen 80;
server_name _;
location /health {
return 200 'Health Check OK';
add_header Content-Type text/plain;
}
}
EOF
mkdir -p deploy
cp -r dist deploy/
cp package.json deploy/
cp server.js deploy/
cp Procfile deploy/
cp -r .ebextensions deploy/
cp -r .platform deploy/
cd deploy && zip -r deploy.zip .
- name: Beanstalk Deploy
uses: einaregilsson/beanstalk-deploy@v22
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: MarketNawaFE
environment_name: MarketNawaFE-env
version_label: github-action-${{ github.sha }}
region: ap-northeast-2
deployment_package: deploy/deploy.zip
use_existing_version_if_available: true