Merge pull request #40 from Sans-arch/features #59
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: Development CI/CD - Build and Deploy React App to CloudFront | |
on: | |
push: | |
branches: [main] | |
jobs: | |
pipeline: | |
name: Deploy to S3 | |
runs-on: ubuntu-latest | |
env: | |
VITE_BACKEND_API: https://api-gamehub.techsan.dev/api | |
BUCKET: gamehub-frontend | |
DIST: dist | |
REGION: us-east-1 | |
DIST_ID: E31X9W3PLVO8RY | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
run: npm install | |
- name: Run Tests | |
run: npm test | |
- name: Build static content | |
run: npm run build | |
- name: Configure AWS crdentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.REGION }} | |
- name: Copy files to the production website with the AWS CLI | |
run: | | |
aws s3 sync --delete ${{ env.DIST }} s3://${{ env.BUCKET }} | |
- name: Copy files to the production website with the AWS CLI | |
run: | | |
aws cloudfront create-invalidation \ | |
--distribution-id ${{ env.DIST_ID }} \ | |
--paths "/*" |