-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from Ong-gi-Jong-gi/deploy/cicd
[DEPLOY] S3 & Cloudfront 배포 자동화 적용
- Loading branch information
Showing
3 changed files
with
67 additions
and
124 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,67 @@ | ||
name: Deploy to Amazon S3 & CloudFront | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
pull_request: | ||
branches: ['main'] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache | ||
id: cache | ||
uses: actions/[email protected] | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build- | ||
${{ runner.os }} | ||
- name: Install Dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: npm install | ||
|
||
- name: Setting .env | ||
run: | | ||
echo "VITE_API_URL=$VITE_API_URL" >> .env | ||
echo "VITE_FIRE_BASE_VAPID=$VITE_FIRE_BASE_VAPID" >> .env | ||
echo "VITE_FIRE_BASE_ID=$VITE_FIRE_BASE_ID" >> .env | ||
echo "VITE_FIRE_BASE_FCM_DOMAIN=$VITE_FIRE_BASE_FCM_DOMAIN" >> .env | ||
echo "VITE_FIRE_BASE_MESSAGE_SENDER_ID=$VITE_FIRE_BASE_MESSAGE_SENDER_ID" >> .env | ||
echo "VITE_FIRE_BASE_APP_ID=$VITE_FIRE_BASE_APP_ID" >> .env | ||
echo "VITE_FIRE_BASE_MEASUREMENT_ID=$VITE_FIRE_BASE_MEASUREMENT_ID" >> .env | ||
echo "VITE_WEBSOCKET_URL=$VITE_WEBSOCKET_URL" >> .env | ||
echo "VITE_NODE_API_URL=$VITE_NODE_API_URL" >> .env | ||
env: | ||
VITE_API_URL: ${{ secrets.VITE_API_URL }} | ||
VITE_FIRE_BASE_VAPID: ${{ secrets.VITE_FIRE_BASE_VAPID }} | ||
VITE_FIRE_BASE_ID: ${{ secrets.VITE_FIRE_BASE_ID }} | ||
VITE_FIRE_BASE_FCM_DOMAIN: ${{ secrets.VITE_FIRE_BASE_FCM_DOMAIN }} | ||
VITE_FIRE_BASE_MESSAGE_SENDER_ID: ${{ secrets.VITE_FIRE_BASE_MESSAGE_SENDER_ID }} | ||
VITE_FIRE_BASE_APP_ID: ${{ secrets.VITE_FIRE_BASE_APP_ID }} | ||
VITE_FIRE_BASE_MEASUREMENT_ID: ${{ secrets.VITE_FIRE_BASE_MEASUREMENT_ID }} | ||
VITE_WEBSOCKET_URL: ${{ secrets.VITE_WEBSOCKET_URL }} | ||
VITE_NODE_API_URL: ${{ secrets.VITE_NODE_API_URL }} | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-region: ${{ secrets.AWS_S3_REGION }} | ||
aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }} | ||
|
||
- name: Deploy to S3 | ||
run: aws s3 sync ./dist s3://${{ secrets.AWS_S3_BUCKET_NAME }} | ||
|
||
- name: Invalidate CloudFront Cache | ||
run: | | ||
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/*" |