Update practice.jsx #19
This file contains hidden or 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: Deploy To S3 and CloudFront | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| publish-capstone-project: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20.19.0" | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build | |
| run: npm run build | |
| env: | |
| CI: false | |
| VITE_BASE_URL: ${{ secrets.VITE_BASE_URL }} | |
| VITE_S3_BUCKET_URL: ${{ secrets.VITE_S3_BUCKET_URL }} | |
| VITE_GOOGLE_REDIRECT_URI: ${{ secrets.VITE_GOOGLE_REDIRECT_URI }} | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v2 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ap-northeast-2 | |
| - name: Test S3 Access | |
| run: aws s3 ls s3://${{ secrets.S3_BUCKET_NAME }} | |
| - name: Upload to S3 | |
| run: aws s3 sync dist s3://${{ secrets.S3_BUCKET_NAME }} --delete | |
| - name: Invalidate CloudFront Cache | |
| run: | | |
| aws cloudfront create-invalidation \ | |
| --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} \ | |
| --paths "/*" |