Skip to content

Commit

Permalink
feat: invalidate past cache for deployments
Browse files Browse the repository at this point in the history
This add an invalidation for cache in each environment when the action is triggered.
  • Loading branch information
johanseto authored and andrey-canon committed Jan 25, 2024
1 parent c91f0eb commit f7334b2
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions .github/workflows/deploy-mfe-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ on:
branches:
- ednx-release/mango.nelp
- ednx-rc/mango.nelp

pull_request:
branches:
- "**ednx-rc**"
jobs:
build:
environment:
environment:
name: ${{ github.ref_name == 'ednx-release/mango.nelp' && 'prod' || 'stage' }}
runs-on: ubuntu-latest
steps:

- name: "Echo job vars"
env:
JOB_VARS: ${{ toJson(vars) }}
run: echo "$JOB_VARS"
run: echo "$JOB_VARS"

- name: checkout mfe repo
uses: actions/checkout@v3

- name: Use Node.js ${{ vars.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ vars.NODE_VERSION }}

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
Expand All @@ -47,10 +47,10 @@ jobs:
name: List the state of node modules
continue-on-error: true
run: npm list

- name: npm Install
run: npm install

- name: npm Build # check env variables of repo.
run: npm run build
env:
Expand All @@ -60,18 +60,18 @@ jobs:
MFE_CONFIG_API_URL: ${{ vars.MFE_CONFIG_API_URL }}
ENABLE_NEW_RELIC: false
NODE_ENV: production

- name: print generated html of mfe
run: cat dist/index.html

- name: Share artifact inside workflow
uses: actions/upload-artifact@v3
with:
name: ${{ vars.APP_ID }}-dist-artifact
path: dist

deployment:
environment:
environment:
name: ${{ github.ref_name == 'ednx-release/mango.nelp' && 'prod' || 'stage' }}
url: ${{ vars.PUBLIC_PATH_CDN }}
runs-on: ubuntu-latest
Expand All @@ -82,7 +82,7 @@ jobs:
uses: actions/download-artifact@v3
with:
name: ${{ vars.APP_ID }}-dist-artifact

- name: "Echo job vars"
env:
JOB_VARS: ${{ toJson(vars) }}
Expand All @@ -100,3 +100,7 @@ jobs:
aws s3 sync . $S3_BUCKET
env:
S3_BUCKET: s3://${{ vars.BUCKET_NAME }}${{ vars.PUBLIC_PATH }} --delete

- name: Invalidate past cloudfront cache
run: |
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"

0 comments on commit f7334b2

Please sign in to comment.