Merge pull request #14 from Spaces-Place/dusqo #20
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: Deploy React App to S3 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' # 필요한 Node.js 버전 설정 | |
- name: Install dependencies | |
run: npm install | |
- name: Build React App | |
run: npm run build | |
env: | |
CI: false | |
- 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: ${{ secrets.AWS_REGION }} | |
- name: Upload to S3 | |
run: | | |
aws s3 sync ./build s3://${{ secrets.S3_BUCKET_NAME }} --delete --acl public-read | |
aws s3 website s3://${{ secrets.S3_BUCKET_NAME }} --index-document index.html --error-document error.html | |
- name: Invlidate CloudFront | |
uses: chetan/invalidate-cloudfront-action@master | |
env: | |
PATHS: '/*' | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
DISTRIBUTION: ${{ secrets.DEV_AWS_DISTRIBUTION_ID }} | |