From 319862cecdce4fc5add0f7a8807bb87dda0848a7 Mon Sep 17 00:00:00 2001 From: Perry Zhu Date: Sat, 11 Oct 2025 20:03:53 -0700 Subject: [PATCH] feat: gha invalidate cache on --- .github/workflows/push-artifacts.yaml | 62 +++++++++++++++------------ 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/.github/workflows/push-artifacts.yaml b/.github/workflows/push-artifacts.yaml index b7eb27c..9712d96 100644 --- a/.github/workflows/push-artifacts.yaml +++ b/.github/workflows/push-artifacts.yaml @@ -1,32 +1,38 @@ # Build artifacts and push to S3 name: Publish to S3 on: - push: - branches: - - main + push: + branches: + - main jobs: - deploy: - runs-on: ubuntu-latest - permissions: - id-token: write - contents: read - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.AWS_IAM_ROLE_ARN }} - aws-region: ${{ secrets.AWS_REGION }} - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: "22" - cache: "yarn" - - name: Install Dependencies - run: yarn install --frozen-lockfile - - name: Build Project - run: yarn build - - name: Deploy to S3 - run: | - aws s3 sync ./dist s3://${{ secrets.AWS_S3_BUCKET }} --delete + deploy: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_IAM_ROLE_ARN }} + aws-region: ${{ secrets.AWS_REGION }} + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + cache: "yarn" + - name: Install Dependencies + run: yarn install --frozen-lockfile + - name: Build Project + run: yarn build + - name: Deploy to S3 + run: | + aws s3 sync ./dist s3://${{ secrets.AWS_S3_BUCKET }} --delete + - name: Invalidate CloudFront cache + uses: foxdalas/cloudfront-invalidator@v4 + with: + tag_key: "Name" + tag_value: ${{ secrets.CLOUDFRONT_DISTRIBUTION_NAME }} + paths: "/*"