-
Notifications
You must be signed in to change notification settings - Fork 25
141 lines (122 loc) · 4.84 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Deployment
on:
pull_request:
branches:
- master
- develop
types: [closed]
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
jobs:
build_and_deploy:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16.14'
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Generate Types (develop)
if: github.base_ref == 'develop'
run: npm run gen:type
- name: Generate Types (production)
if: github.base_ref == 'master'
run: npm run gen:type:prod
- name: Lint
run: |
npm run i18n \
&& npm run lint \
&& npm run format:check
# - name: Test
# run: npm install codecov -g && npm run test && codecov
# env:
# CODECOV_TOKEN: f109cbf6-b6c7-4a08-ad03-981bc4cd1fe8
# MATTERS_ENV: test
# API_URL: http://matters-server-develop.ap-southeast-1.elasticbeanstalk.com/graphql
# - name: Test - BDD
# === `develop` branch ===
- name: Build (develop)
if: github.base_ref == 'develop'
run: cp .env.dev .env.local && npm run build
# === `master` branch ===
- name: Build (production)
if: github.base_ref == 'master'
run: cp .env.prod .env.local && npm run build
- name: Setup AWS
if: github.base_ref == 'develop' || github.base_ref == 'master'
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-southeast-1
- name: Generate deployment package
if: github.base_ref == 'develop' || github.base_ref == 'master'
run: |
rm -rf node_modules \
&& npm install --production \
&& zip -r --symlinks deploy.zip . -x .git/\*
- name: Upload Assets (develop - R2)
if: github.base_ref == 'develop'
uses: andreiio/rclone-action@v1
env:
RCLONE_CONFIG_R2_TYPE: s3
RCLONE_CONFIG_R2_PROVIDER: Cloudflare
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.RCLONE_CONFIG_R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.RCLONE_CONFIG_R2_SECRET_ACCESS_KEY }}
RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.RCLONE_CONFIG_R2_ENDPOINT }}
with:
args: sync .next/static r2:matters-assets-next-develop/_next/static -P
- name: Deploy to EB (develop)
if: github.base_ref == 'develop'
uses: einaregilsson/beanstalk-deploy@v19
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: matters-stage
environment_name: matters-client-develop
version_label: matters-web-develop-${{ hashFiles('deploy.zip') }}
version_description: ${{ github.SHA }}
region: ap-southeast-1
deployment_package: deploy.zip
use_existing_version_if_available: true
wait_for_deployment: true
- name: Upload Assets (production - R2)
if: github.base_ref == 'master'
uses: andreiio/rclone-action@v1
env:
RCLONE_CONFIG_R2_TYPE: s3
RCLONE_CONFIG_R2_PROVIDER: Cloudflare
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.RCLONE_CONFIG_R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.RCLONE_CONFIG_R2_SECRET_ACCESS_KEY }}
RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.RCLONE_CONFIG_R2_ENDPOINT }}
with:
args: sync .next/static r2:matters-assets-next/_next/static -P
- name: Deploy to EB (production)
if: github.base_ref == 'master'
uses: einaregilsson/beanstalk-deploy@v19
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: matters-prod
environment_name: matters-client-prod
version_label: matters-web-prod-${{ hashFiles('deploy.zip') }}
version_description: ${{ github.SHA }}
region: ap-southeast-1
deployment_package: deploy.zip
use_existing_version_if_available: true
wait_for_deployment: true
- name: Slack Notification
if: always()
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: matters-web
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took