Skip to content

Commit

Permalink
feat: prepare live deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
saehun committed Aug 12, 2023
1 parent fdd8baf commit c835884
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/deploy-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: ['master']

env:
STAGE: 'dev'
NEXT_PUBLIC_STAGE: 'dev'

# AWS
AWS_REGION: 'ap-northeast-2'
AWS_HOST_ZONE: ${{ secrets.AWS_HOST_ZONE }}
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: deploy-prod

on:
release:
types:
- created

env:
STAGE: 'prod'
NEXT_PUBLIC_STAGE: 'prod'

# AWS
AWS_REGION: 'ap-northeast-2'
AWS_HOST_ZONE: ${{ secrets.AWS_HOST_ZONE }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

# DOMAIN
DOMAIN_NAME: ${{ secrets.DOMAIN_NAME }}
DOMAIN_NAME_API: api.${{ secrets.DOMAIN_NAME }}
NEXT_PUBLIC_API_HOST: api.${{ secrets.DOMAIN_NAME }}
S3_PRIVATE_BUCKET: ${{ secrets.S3_PRIVATE_BUCKET }}

# SENTRY
WEB_SENTRY_DSN: ${{ secrets.WEB_SENTRY_DSN }}

jobs:
deploy-dev:
name: deploy to development environment
timeout-minutes: 15
runs-on: ubuntu-latest
# To use Remote Caching, uncomment the next lines and follow the steps below.
# env:
# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
# TURBO_TEAM: ${{ vars.TURBO_TEAM }}

steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2

- uses: pnpm/[email protected]
with:
version: 8.6.3

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm build

- name: Deploy development
run: pnpm deploy:dev
2 changes: 1 addition & 1 deletion packages/api/src/clientFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { authTokenRepository } from './AuthTokenRepository';

export function createApiClient({ auth }: { auth: boolean }) {
const client = axios.create({
baseURL: 'https://' + 'api.dev.ppoba.app' + '/v1',
baseURL: 'https://' + process.env.NEXT_PUBLIC_API_HOST + '/v1',
});

if (auth) {
Expand Down
1 change: 1 addition & 0 deletions packages/service-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"scripts": {
"build": "tsc -p tsconfig.build.json --noEmit && npx webpack",
"deploy:dev": "STAGE=dev make all",
"deploy:prod": "STAGE=prod make all",
"dev": "ts-node src/entry.local.ts",
"dev:debug": "node --require ts-node/register --inspect-brk src/entry.local.ts",
"lint": "eslint . --ext .js,.ts",
Expand Down
4 changes: 3 additions & 1 deletion packages/service-frontend/app/deck/[id]/DeckDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ export default function DeckDetail({ params }: Props): JSX.Element {
const result = await share({
title: 'PPOBA - 뽀바',
text: '뽀바, 너만의 카드게임을 즐겨봐',
url: `https://dev.ppoba.app/deck/${params.id}`,
url: `https://${
process.env.NEXT_PUBLIC_STAGE === 'prod' ? '' : 'dev.'
}ppoba.app/deck/${params.id}`,
})
if (result === 'copiedToClipboard') {
alert('링크를 클립보드에 복사했습니다.')
Expand Down
6 changes: 3 additions & 3 deletions packages/service-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"private": true,
"scripts": {
"build": "next build",
"deploy:dev": "sst deploy --stage dev",
"deploy:prod": "sst deploy --stage prod",
"deploy:dev": "STAGE=dev sst deploy --stage dev",
"deploy:prod": "STAGE=prod sst deploy --stage prod",
"dev": "next dev",
"lint": "next lint",
"test": "jest",
Expand Down Expand Up @@ -56,4 +56,4 @@
"sst": "^2.8.27",
"ts-jest": "^29.1.0"
}
}
}
3 changes: 2 additions & 1 deletion packages/service-frontend/sst.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NextjsSite } from 'sst/constructs'
export default {
config(_input) {
return {
name: 'ppoba-frontend',
name: `ppoba-frontend`,
region: 'ap-northeast-2',
}
},
Expand All @@ -17,6 +17,7 @@ export default {
},
runtime: 'nodejs18.x',
environment: {
NEXT_PUBLIC_STAGE: process.env.STAGE!,
NEXT_PUBLIC_API_HOST: process.env.DOMAIN_NAME_API!,
NEXT_PUBLIC_WEB_SENTRY_DSN: process.env.WEB_SENTRY_DSN!,
},
Expand Down

0 comments on commit c835884

Please sign in to comment.