forked from codesquad-members-2024/issue-tracker
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Deploy React to S3 | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
# 워크플로우가 저장소의 콘텐츠를 읽을 수 있는 권한을 갖도록 설정 | ||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Cache node modules | ||
uses: actions/cache@v4 | ||
with: | ||
path: ./FE/node_modules | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
${{ runner.OS }}- | ||
- name: Install dependencies | ||
run: npm install | ||
working-directory: ./FE | ||
|
||
- name: Build | ||
run: npm run build | ||
working-directory: ./FE | ||
env: | ||
VITE_TEAM_SERVER: ${{ secrets.VITE_TEAM_SERVER }} | ||
VITE_TEAM_CLIENT: ${{ secrets.VITE_TEAM_CLIENT }} | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.S3_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.S3_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.S3_REGION }} | ||
|
||
- name: SHOW AWS CLI VERSION | ||
env: | ||
AWS_EC2_METADATA_DISABLED: true | ||
run: | | ||
aws s3 sync \ | ||
dist s3://issue-tracker-02 \ | ||
--delete | ||
working-directory: ./FE | ||
|
||
- name: Invalidate CloudFront Cache | ||
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |