Update main.yml #4
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: Client CI/CD | |
| on: | |
| push: | |
| paths: | |
| - "**" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| client-CI-CD: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Branch | |
| uses: actions/checkout@v4 | |
| - name: Node.js 18.x Version | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| cache: "npm" | |
| cache-dependency-path: package-lock.json | |
| - name: Build | |
| run: | | |
| npm install | |
| npm run build | |
| - name: Configure AWS credentials | |
| if: ${{ github.ref == 'refs/heads/main' }} | |
| uses: aws-actions/configure-aws-credentials@v3 | |
| 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: Deploy to Main S3 and Invalidate CloudFront cache | |
| if: ${{ github.ref == 'refs/heads/main' }} | |
| run: | | |
| aws s3 sync ./build s3://${{ secrets.AWS_S3_CLIENT_MAIN_BUCKET_NAME }} | |
| aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_MAIN_DISTRIBUTION_ID }} --paths "/*" |