Skip to content

Commit b039d03

Browse files
committed
feat: add stage
1 parent 7e3de4f commit b039d03

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

.github/workflows/stage.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- stage
7+
8+
jobs:
9+
deploy:
10+
name: deploy
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@master
14+
- name: Setup Node.js 16.x
15+
uses: actions/setup-node@v2
16+
with:
17+
node-version: '16.x'
18+
- name: Get yarn cache
19+
id: yarn-cache
20+
run: echo "::set-output name=dir::$(yarn cache dir)"
21+
22+
- uses: actions/cache@v3
23+
with:
24+
path: ${{ steps.yarn-cache.outputs.dir }}
25+
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('**/yarn.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-yarn-
28+
- name: yarn install
29+
uses: borales/[email protected]
30+
with:
31+
cmd: install
32+
- name: npm run build:ci
33+
run: npm run build:ci
34+
env:
35+
REACT_APP_API_HOST: 'https://v2.velog.io/'
36+
REACT_APP_GRAPHQL_HOST: 'https://v2.velog.io/'
37+
REACT_APP_GRAPHQL_HOST_NOCDN: 'https://v2.velog.io/'
38+
PUBLIC_URL: 'https://stage-assets.velog.io/assets'
39+
REACT_APP_REDIS_HOST: ${{ secrets.REDIS_HOST }}
40+
REACT_APP_CLIENT_V3_HOST: 'https://velog.io'
41+
REACT_APP_WHITELIST_IPS: ${{ secrets.REACT_APP_WHITELIST_IPS }}
42+
REACT_APP_STAGE: true
43+
CI: false
44+
- name: upload
45+
env:
46+
S3_BUCKET_STAGE: ${{ secrets.AWS_S3_BUCKET_STAGE }}
47+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
48+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
49+
AWS_REGION: 'ap-northeast-2'
50+
run: |
51+
yarn upload:stage
52+
yarn upload:ssr:stage

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@
174174
"upload": "aws s3 cp --recursive ./build s3://$S3_BUCKET",
175175
"upload:ssr": "aws s3 cp --recursive ./dist s3://$S3_BUCKET_SSR",
176176
"download": "aws s3 cp s3://$S3_BUCKET ./build/ --recursive && aws s3 cp s3://$S3_BUCKET_SSR ./dist/ --recursive",
177+
"upload:stage": "aws s3 cp --recursive ./build s3://$S3_BUCKET_STAGE/assets",
178+
"upload:ssr:stage": "aws s3 cp --recursive ./dist s3://$S3_BUCKET_STAGE/ssr",
179+
"download:stage": "aws s3 cp s3://$S3_BUCKET/assets ./build/ --recursive && aws s3 cp s3://$S3_BUCKET_STAGE/ssr ./dist/ --recursive",
177180
"deploy": "pm2 reload deploy.config.json"
178181
},
179182
"eslintConfig": {

src/server/CacheManager.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ export const redis = new Redis({
55
host: process.env.REACT_APP_REDIS_HOST || 'localhost',
66
});
77

8+
const env = process.env.REACT_APP_STAGE === 'true' ? 'stage:' : '';
9+
810
function createCacheKey(url: string) {
9-
return `ssr:${url}`;
11+
return `ssr:${env}${url}`;
1012
}
1113

1214
export default class CacheManager {

0 commit comments

Comments
 (0)