Merge pull request #267 from edu-pi/develop #16
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: Build React App and Deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20.x" | |
# .env 파일 생성 | |
- name: Create .env File | |
run: | | |
echo "VITE_APP_BACKEND_BASE_URL=${{ secrets.VITE_APP_BACKEND_BASE_URL }}" >> .env | |
echo "VITE_APP_NODE_ENV=${{ secrets.VITE_APP_NODE_ENV }}" >> .env | |
echo "VITE_APP_FRONT_BASE_URL=${{ secrets.VITE_APP_FRONT_BASE_URL }}" >> .env | |
- name: Npm Install | |
run: npm install | |
- name: Npm Build | |
run: npm run build | |
- name: Deploy to S3 | |
uses: jakejarvis/s3-sync-action@master | |
with: | |
args: --delete | |
env: | |
AWS_S3_BUCKET: ${{ secrets.AWS_STAGING_BUCKET_NAME }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
SOURCE_DIR: "dist" | |
- name: Invalidate CloudFront | |
run: | | |
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} |