Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add clear cache for publish action #2129

Merged
merged 2 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,23 @@ jobs:
uses: actions/download-artifact@v3
- name: Publish to S3
run: npm run publish-cdn

invalidate-cache:
name: Clear cache
runs-on: ubuntu-latest
needs: [check-version, publish-npm, publish-cli-s3, publish-cdn]
if: needs.check-version.outputs.changed == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Configure AWS
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: us-east-1
- name: Invalidate cache
run: ./scripts/invalidate-cache.sh
shell: bash
env:
DISTRIBUTION: ${{ secrets.DISTRIBUTION }}
24 changes: 24 additions & 0 deletions scripts/invalidate-cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -e # exit on error

echo jsdelivr clearing cache
curl -i -X POST https://purge.jsdelivr.net/ \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"path": [
"npm/redoc@latest/bundles/redoc.browser.lib.js",
"npm/redoc@latest/bundles/redoc.lib.js",
"npm/redoc@latest/bundles/redoc.standalone.js"
]
}'

echo
echo start invalidate cloudfront

aws cloudfront create-invalidation --distribution-id $DISTRIBUTION --paths "/redoc/*"

echo Cache cleared successfully

exit 0