Skip to content

Commit

Permalink
🚀 snutt-map-webview dev 배포 설정 (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
woohm402 authored Jan 6, 2024
1 parent 15e0e5d commit dce794b
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: deploy-dev
name: deploy-friends-react-native-dev

on:
push:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: deploy-prod
name: deploy-friends-react-native-prod

on:
push:
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/deploy-map-webview-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: deploy-map-webview-dev

on:
push:
tags:
- map-webview-dev-*

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest

defaults:
run:
working-directory: apps/map-webview

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Build & Export
run: |
yarn install
yarn build
- name: Deploy to S3 and Invalidate Cloudfront
id: deploy-s3
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_SNUTT_MAP_WEBVIEW_DEV }}
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID_SNUTT_MAP_WEBVIEW_DEV }}
run: |
aws s3 sync ./dist s3://$AWS_S3_BUCKET --delete
aws cloudfront create-invalidation --distribution-id $AWS_CLOUDFRONT_DISTRIBUTION_ID --paths "/*"
3 changes: 2 additions & 1 deletion apps/map-webview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"build": "tsc && vite build",
"lint": "eslint src",
"preview": "vite preview",
"tsc": "tsc"
"tsc": "tsc",
"deploy:dev": "scripts/deploy.sh dev"
},
"dependencies": {
"react": "18.2.0",
Expand Down
32 changes: 32 additions & 0 deletions apps/map-webview/scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

env=$1

today=$(date +%y.%m.%d)
tagFormat="map-webview-${env}-${today}-"

git fetch --all --tags
tagCount=$(git tag -l | grep -c $tagFormat)

newTagNumber=$(($tagCount + 1))
newTagName="${tagFormat}${newTagNumber}"

echo
echo "=================================="
echo
echo " Created tag: \033[1m${newTagName}\033[0m "
echo
echo "=================================="
echo
read -p "Are you sure to push this tag? (Y/n) " -n 1 -r
echo

if [[ $REPLY =~ ^[Yy]$ ]]; then
git tag -a $newTagName -m $newTagName
git push origin $newTagName
else
echo
echo "\033[31mCanceled.\033[0m"
echo
exit 1
fi

0 comments on commit dce794b

Please sign in to comment.