Merge pull request #288 from UPbrella/release-dev #35
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
name: FE Production Deploy | |
on: | |
push: | |
branches: ["release"] | |
env: | |
working-directory: ./ | |
ESLINT_NO_DEV_ERRORS: true | |
permissions: | |
contents: read | |
jobs: | |
prepare: | |
name: Prepare Build | |
runs-on: ubuntu-latest | |
outputs: | |
tag_date: ${{ steps.tag.outputs.date }} | |
tag_git_hash: ${{ steps.tag.outputs.git_hash }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get time TAG | |
id: tag | |
run: | | |
echo "date=$(date +'%Y%m%d.%H%M')" >> $GITHUB_OUTPUT | |
echo "git_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
build: | |
runs-on: ubuntu-latest | |
needs: prepare | |
permissions: | |
contents: read | |
id-token: write | |
outputs: | |
tag_date: ${{ steps.tag.outputs.date }} | |
tag_git_hash: ${{ steps.tag.outputs.git_hash }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
# Github Repository Secrets를 통해 .env 파일을 생성 | |
- name: Generate Environment Variables File for Production | |
env: | |
VITE_UPBRELLA_API_BASE_URL: ${{ secrets.VITE_UPBRELLA_API_BASE_URL_PROD }} | |
VITE_NAVER_MAP_API_KEY: ${{ secrets.VITE_NAVER_MAP_API_KEY }} | |
VITE_KAKAO_MAP_API_KEY: ${{ secrets.VITE_KAKAO_MAP_API_KEY }} | |
VITE_KAKAO_LOGIN_REST_API_KEY: ${{ secrets.VITE_KAKAO_LOGIN_REST_API_KEY }} | |
VITE_EMAIL_SERVICE_ID: ${{ secrets.VITE_EMAIL_SERVICE_ID }} | |
VITE_EMAIL_TEMPLATE_ID: ${{ secrets.VITE_EMAIL_TEMPLATE_ID}} | |
VITE_EMAIL_PUB_KEY: ${{ secrets.VITE_EMAIL_PUB_KEY}} | |
run: | | |
echo "VITE_UPBRELLA_API_BASE_URL=${VITE_UPBRELLA_API_BASE_URL}" >> .env | |
echo "VITE_NAVER_MAP_API_KEY=${VITE_NAVER_MAP_API_KEY}" >> .env | |
echo "VITE_KAKAO_MAP_API_KEY=${VITE_KAKAO_MAP_API_KEY}" >> .env | |
echo "VITE_KAKAO_LOGIN_REST_API_KEY=${VITE_KAKAO_LOGIN_REST_API_KEY}" >> .env | |
echo "VITE_EMAIL_SERVICE_ID"=${VITE_EMAIL_SERVICE_ID} >> .env | |
echo "VITE_EMAIL_TEMPLATE_ID"=${VITE_EMAIL_TEMPLATE_ID} >> .env | |
echo "VITE_EMAIL_PUB_KEY"=${VITE_EMAIL_PUB_KEY} >> .env | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
run: npm install | |
- name: Generate build | |
run: npm run build | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Upload to S3 | |
run: | | |
aws s3 sync ./dist/ s3://${{ secrets.S3_BUCKET_NAME }} --region ${{ secrets.AWS_REGION }} | |
- name: Invalidate CloudFront Cache | |
run: | | |
aws cloudfront create-invalidation --distribution-id ${{ secrets.DISTRIBUTION_ID }} --paths "/*" |