Skip to content

Commit

Permalink
Merge pull request #111 from wafflestudio/feat/dotenv
Browse files Browse the repository at this point in the history
배포 페이즈 별 환경 설정 및 github action 개선 및 PR 템플릿 간소화
  • Loading branch information
minkyu97 authored Dec 27, 2023
2 parents 340d347 + b396016 commit 3d853d3
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 59 deletions.
3 changes: 3 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VITE_BASE_URL=https://wacruit-dev.wafflestudio.com/api/v1
VITE_SSO_LOGIN_URL=https://sso-dev.wafflestudio.com
VITE_SSO_REDIRECT_URL=https://wacruit-dev.wafflestudio.com/sso
3 changes: 3 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VITE_BASE_URL=https://wacruit.wafflestudio.com/api/v1
VITE_SSO_LOGIN_URL=https://sso.wafflestudio.com
VITE_SSO_REDIRECT_URL=https://wacruit.wafflestudio.com/sso
28 changes: 9 additions & 19 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
### 요약
- 마감 기한: YY-MM-DD
- 상태: <!-- 상태: 시작 안 함 / 진행 중 / 리뷰 필요 / 머지 필요 -->
## 요약
<!-- 1줄 요약 -->

### 태스크 URL
## 변경 내역
<!-- 가능한 상세히 작성 -->

### 체크리스트
__PR 전__
- [ ] 칸반 생성
- [ ] pre-commit 성공
- [ ] type-label 추가
## 체크리스트
- [ ] pre-commit 통과
- [ ] PR Assignees 추가
- [ ] PR Labels 추가

__머지 전__
- [ ] 칸반 옮기기
- [ ] 코멘트 리졸브
- [ ] squash & merge

### 작업 목록

### 테스트 방법 (Optional)

### 기타 질문 및 공유 사항 (Optional)
## 기타 질문 및 공유 사항 (Optional)
18 changes: 12 additions & 6 deletions .github/workflows/dev.yml → .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ name: Dev CICD
on:
push:
branches: main

concurrency:
group: deploy-dev
cancel-in-progress: true

jobs:
Build:
Deploy:
runs-on: ubuntu-latest
environment: dev
steps:
- name: Checkout
uses: actions/[email protected]
Expand All @@ -16,22 +22,22 @@ jobs:
- name: Install dependencies
run: yarn
- name: Build
run: yarn build
run: yarn build --mode development
- name: Upload to S3
uses: jakejarvis/s3-sync-action@master
with:
args: --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_DEV }}
AWS_S3_BUCKET: ${{ vars.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{secrets.AWS_REGION}}
AWS_REGION: ${{vars.AWS_REGION}}
SOURCE_DIR: "dist"
- name: Invalidate Cloudfront cache
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_DEV }}
DISTRIBUTION: ${{ vars.AWS_CLOUDFRONT_DISTRIBUTION }}
PATHS: "/*"
AWS_REGION: ${{secrets.AWS_REGION}}
AWS_REGION: ${{vars.AWS_REGION}}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Release 배포용 CI/CD workflow.

name: Release CICD
name: Prod CICD
on:
push:
branches: release

concurrency:
group: deploy-prod
cancel-in-progress: true

jobs:
Build:
Deploy:
runs-on: ubuntu-latest
environment: prod
steps:
- name: Checkout
uses: actions/[email protected]
Expand All @@ -18,22 +22,22 @@ jobs:
- name: Install dependencies
run: yarn
- name: Build
run: yarn build
run: yarn build --mode production
- name: Upload to S3
uses: jakejarvis/s3-sync-action@master
with:
args: --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_RELEASE }}
AWS_S3_BUCKET: ${{ vars.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{secrets.AWS_REGION}}
AWS_REGION: ${{vars.AWS_REGION}}
SOURCE_DIR: "dist"
- name: Invalidate Cloudfront cache
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_RELEASE }}
DISTRIBUTION: ${{ vars.AWS_CLOUDFRONT_DISTRIBUTION }}
PATHS: "/*"
AWS_REGION: ${{secrets.AWS_REGION}}
AWS_REGION: ${{vars.AWS_REGION}}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
6 changes: 3 additions & 3 deletions src/apis/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Cookies from "js-cookie";
import { ssoLoginURL, ssoRedirectURI } from "./environment";
import { SSO_LOGIN_URL, SSO_REDIRECT_URL } from "./environment";
import { getRequest } from "./utility";

const SSO_COOKIE_KEY = "waffle.access-token";
Expand All @@ -15,11 +15,11 @@ export const getSsoToken = (): string | null => {
};

export const deleteSsoToken = () => {
Cookies.remove(SSO_COOKIE_KEY, { path:"/", domain:".wafflestudio.com" });
Cookies.remove(SSO_COOKIE_KEY, { path: "/", domain: ".wafflestudio.com" });
};

export const tryLogin = (recruit_id: number | "home") => {
location.href = `${ssoLoginURL}${ssoRedirectURI(recruit_id)}`;
location.href = `${SSO_LOGIN_URL}/?redirect_uri=${SSO_REDIRECT_URL}/${recruit_id}`;
};

export const checkAuth = (): Promise<"invalid" | "valid" | "need_register"> =>
Expand Down
20 changes: 5 additions & 15 deletions src/apis/environment.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
export const baseURL =
import.meta.env.VITE_API_TYPE === "MSW"
? ""
: "https://wacruit-dev.wafflestudio.com/api/v1";
export const BASE_URL =
import.meta.env.VITE_API_TYPE === "MSW" ? "" : import.meta.env.VITE_BASE_URL;

export const ssoLoginURL =
export const SSO_LOGIN_URL =
import.meta.env.VITE_API_TYPE === "MSW"
? ""
: "https://sso-dev.wafflestudio.com/?redirect_uri=";

export const ssoRedirectURI = (recruitId: number | "home") =>
`https://wacruit-dev.wafflestudio.com/sso/${recruitId}`;

// export const baseURL = "https://wacruit.wafflestudio.com/api/v1";

// export const ssoLoginURL = "https://sso.wafflestudio.com/?redirect_uri=";
: import.meta.env.VITE_SSO_LOGIN_URL;

// export const ssoRedirectURI = (recruitId: number | "home") =>
// `https://wacruit.wafflestudio.com/sso/${recruitId}`;
export const SSO_REDIRECT_URL = import.meta.env.VITE_SSO_REDIRECT_URL;
14 changes: 7 additions & 7 deletions src/apis/utility.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getSsoToken } from "./auth";
import { baseURL } from "./environment";
import { BASE_URL } from "./environment";

const defaultCommonHeader = {};

Expand All @@ -23,7 +23,7 @@ export const getRequest = <Response>(
header: HeadersInit = {},
authorized = true,
): Promise<Response> =>
fetch(`${baseURL}${url}`, {
fetch(`${BASE_URL}${url}`, {
headers: {
...defaultCommonHeader,
...header,
Expand All @@ -37,7 +37,7 @@ export const postRequest = <Response>(
header: HeadersInit = {},
authorized = true,
): Promise<Response> =>
fetch(`${baseURL}${url}`, {
fetch(`${BASE_URL}${url}`, {
method: "POST",
headers: {
...defaultCommonHeader,
Expand All @@ -54,7 +54,7 @@ export const putRequest = <Response>(
header: HeadersInit = {},
authorized = true,
): Promise<Response> =>
fetch(`${baseURL}${url}`, {
fetch(`${BASE_URL}${url}`, {
method: "PUT",
headers: {
...defaultCommonHeader,
Expand All @@ -71,7 +71,7 @@ export const patchRequest = <Response>(
header: HeadersInit = {},
authorized = true,
): Promise<Response> =>
fetch(`${baseURL}${url}`, {
fetch(`${BASE_URL}${url}`, {
method: "PATCH",
headers: {
...defaultCommonHeader,
Expand All @@ -88,7 +88,7 @@ export const deleteRequest = <Response>(
header: HeadersInit = {},
authorized = true,
) =>
fetch(`${baseURL}${url}`, {
fetch(`${BASE_URL}${url}`, {
method: "DELETE",
headers: {
...defaultCommonHeader,
Expand All @@ -107,7 +107,7 @@ export const sseRequest = <Response extends { type: string; data: unknown }>(
authorized = true,
): AsyncIterable<Response> => ({
async *[Symbol.asyncIterator]() {
const response = await fetch(`${baseURL}${url}`, {
const response = await fetch(`${BASE_URL}${url}`, {
method: "POST",
headers: {
...defaultCommonHeader,
Expand Down

0 comments on commit 3d853d3

Please sign in to comment.