-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FE] github actions 으로 cd 를 구축한다. #1016
Merged
Merged
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f501172
fix: 복구
ooherin aee63d6
Merge branch 'dev-fe' of https://github.com/woowacourse-teams/2024-ba…
ooherin e660e67
Merge branch 'dev-fe' of https://github.com/woowacourse-teams/2024-ba…
ooherin 800f221
fix: 충돌 해결
ooherin cf910ac
Merge branch 'dev-fe' of https://github.com/woowacourse-teams/2024-ba…
ooherin 43c4de2
Merge branch 'dev-fe' of https://github.com/woowacourse-teams/2024-ba…
ooherin 12c4023
Merge branch 'dev-fe' of https://github.com/woowacourse-teams/2024-ba…
ooherin cc03c71
feat: github-actions cd dev 설정
ooherin 0a653e2
fix: cd 수정
ooherin 60b46b8
Merge branch 'dev-fe' into feat/1013-cd
ooherin d705c38
fix: cd 들여쓰기 수정
ooherin d23d9b3
Merge branch 'feat/1013-cd' of https://github.com/woowacourse-teams/2…
ooherin 3f784e6
fix: cd 이름 수정
ooherin ab13999
fix: cd 에 환경 변수 추가
ooherin 93722a2
fix: 테스트용 명령어 추가
ooherin 4aef295
fix: cd 트리거
ooherin 02ddc08
feat: prod cd 생성
ooherin b4c3e51
fix: 불필요한 cd 트리거 코드 삭제
ooherin ce1d2e5
fix: 리뷰 반영
ooherin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,60 @@ | ||
name: Deploy Development to S3 and invalidate CloudFront Cache | ||
|
||
name: frontend-dev-cd | ||
on: | ||
push: | ||
branches: | ||
- dev-fe #dev-fe가 trigger 브랜치 | ||
- dev-fe | ||
paths: | ||
- "frontend/**" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
|
||
environment: frontend-development | ||
steps: | ||
# 1. 소스코드 체크아웃 | ||
- name: Checkout Source Code | ||
uses: actions/checkout@v3 | ||
|
||
# 2. Node.js 설치 (필요시) | ||
- name: Node.js | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: "npm" | ||
node-version: 16 | ||
|
||
# 3. 빌드 | ||
- run: npm --force ci | ||
|
||
- name: Build Production | ||
run: CI=false npm run build --if-present | ||
- name: Checkout Source Code | ||
uses: actions/checkout@v3 | ||
|
||
# 4. AWS Credentials 설정 | ||
- name: Configure AWS credentials | ||
- name: Generate .env File | ||
working-directory: ./frontend | ||
run: | | ||
echo "API_ENV=${{ secrets.API_ENV }}" >> .env | ||
echo "API_URL=${{ secrets.API_URL }}" >> .env | ||
echo "REDIRECT_URI=${{ secrets.REDIRECT_URI }}" >> .env | ||
echo "CLIENT_ID=${{ secrets.CLIENT_ID }}" >> .env | ||
echo "KAKAO_MAP_KEY=${{ secrets.KAKAO_MAP_KEY }}" >> .env | ||
echo "SENTRY_DSN_TOKEN=${{ secrets.SENTRY_DSN_TOKEN }}" >> .env | ||
echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> .env | ||
echo "SENTRY_ORG=${{ secrets.SENTRY_ORG }}" >> .env | ||
echo "SENTRY_PROJECT=${{ secrets.SENTRY_PROJECT }}" >> .env | ||
echo "ANALYZE_BUNDLE=${{ secrets.ANALYZE_BUNDLE }}" >> .env | ||
echo "CI=${{ secrets.CI }}" >> .env | ||
echo "AMPLITUDE_API_KEY=${{ secrets.AMPLITUDE_API_KEY }}" >> .env | ||
|
||
- name: Install Dependencies | ||
working-directory: ./frontend | ||
run: npm install | ||
|
||
- name: Build for Dev | ||
working-directory: ./frontend | ||
run: npm run build:dev-fe | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ap-northeast-2 # 서울 리전 | ||
aws-region: ap-northeast-2 | ||
|
||
# 5. S3에 파일 업로드 | ||
- name: Deploy to S3 | ||
working-directory: ./frontend/dist | ||
run: | | ||
aws s3 sync build/ s3://dev-fe.bang-ggood.com --delete | ||
aws s3 sync . s3://${{secrets.S3_BUCKET}} --delete | ||
|
||
# 6. CloudFront 캐시 무효화 | ||
- name: Invalidate CloudFront Cache | ||
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.DEV_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" | ||
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: frontend-prod-cd | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "frontend/**" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
environment: frontend-production | ||
steps: | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Checkout Source Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Generate .env File | ||
working-directory: ./frontend | ||
run: | | ||
echo "API_ENV=${{ secrets.API_ENV }}" >> .env | ||
echo "API_URL=${{ secrets.API_URL }}" >> .env | ||
echo "REDIRECT_URI=${{ secrets.REDIRECT_URI }}" >> .env | ||
echo "CLIENT_ID=${{ secrets.CLIENT_ID }}" >> .env | ||
echo "KAKAO_MAP_KEY=${{ secrets.KAKAO_MAP_KEY }}" >> .env | ||
echo "SENTRY_DSN_TOKEN=${{ secrets.SENTRY_DSN_TOKEN }}" >> .env | ||
echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> .env | ||
echo "SENTRY_ORG=${{ secrets.SENTRY_ORG }}" >> .env | ||
echo "SENTRY_PROJECT=${{ secrets.SENTRY_PROJECT }}" >> .env | ||
echo "ANALYZE_BUNDLE=${{ secrets.ANALYZE_BUNDLE }}" >> .env | ||
echo "CI=${{ secrets.CI }}" >> .env | ||
echo "AMPLITUDE_API_KEY=${{ secrets.AMPLITUDE_API_KEY }}" >> .env | ||
|
||
- name: Install Dependencies | ||
working-directory: ./frontend | ||
run: npm install | ||
|
||
- name: Build for Prod | ||
working-directory: ./frontend | ||
run: npm run build | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
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: Deploy to S3 | ||
working-directory: ./frontend/dist | ||
run: | | ||
aws s3 sync . s3://${{secrets.S3_BUCKET}} --delete | ||
|
||
- name: Invalidate CloudFront Cache | ||
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ const S = { | |
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; /* 전체 화면 높이에 맞춰 정렬 */ | ||
height: 100vh; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
background-color: ${({ theme }) => theme.palette.white}; | ||
`, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
프로젝트나 기존 yml 파일들도 모두 yarn인 만큼 npm말고 yarn으로 통일하는 게 좋을거같습니다!
CI 시간단축에도 도움이 되고요
yarn을 쓰려면 node버전이 16.10이상이어야해서 node-version: 18.x을 해두시면 될 거 같네요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
와 이부분은 빠트렸네요!! 역시 제이드입니다 👍👍