Merge pull request #7 from StopSoo/forked #11
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: Client CI/CD | |
on: | |
push: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
client-CI-CD: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Branch | |
uses: actions/checkout@v4 | |
- name: Set up Node.js and pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: "pnpm" | |
- name: Install Dependencies, Lint, and Build | |
run: | | |
pnpm install | |
pnpm 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 "/*" |