Skip to content

Commit efbc5c9

Browse files
Matteo-itSerjlee
andauthored
Add pdf sync and invalidate old cloudflare cache (#2077)
* Add pdf sync and invalidate old cloudflare cache * Update PDF sync * Update staging pdf sync * update typo * Api token * Exclude pdf from old sync assets * Set invalidation prefix * Use cURL --------- Co-authored-by: Luca Osti <[email protected]>
1 parent 1f9528f commit efbc5c9

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

.github/workflows/deploy-production.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,18 @@ jobs:
7373
aws-region: us-east-1
7474

7575
- name: Sync all cacheable assets
76-
run: aws s3 sync --cache-control "public, max-age=31536000, immutable" --include "*.css" --include="*.js" --include="*.gif" --include="*.png" --include="*.svg" --exclude "*.html" --exclude="sw.js" --exclude="*.json" --delete public/ s3://${{ secrets.PRODUCTION_BUCKET_NAME }}/
76+
run: aws s3 sync --cache-control "public, max-age=31536000, immutable" --include "*.css" --include="*.js" --include="*.gif" --include="*.png" --include="*.svg" --exclude "*.html" --exclude="sw.js" --exclude="*.json" --exclude="*.pdf" --delete public/ s3://${{ secrets.PRODUCTION_BUCKET_NAME }}/
7777

7878
- name: Sync all non-cacheable assets
7979
# Don't cache any HTML or JSON file: they should always be up-to-dates
80-
run: aws s3 sync --cache-control "public, max-age=0, must-revalidate" --include "*.html" --include="sw.js" --include="*.json" --include "*.css" --exclude="*.js" --exclude="*.gif" --exclude="*.png" --exclude="*.svg" --delete public/ s3://${{ secrets.PRODUCTION_BUCKET_NAME }}/
80+
run: aws s3 sync --cache-control "public, max-age=0, must-revalidate" --include "*.html" --include="sw.js" --include="*.json" --include "*.css" --exclude="*.js" --exclude="*.gif" --exclude="*.png" --exclude="*.svg" --exclude="*.pdf" --delete public/ s3://${{ secrets.PRODUCTION_BUCKET_NAME }}/
81+
82+
- name: Sync PDF
83+
run: aws s3 sync --cache-control "public, max-age=86400, must-revalidate" --include "*.pdf" --exclude="*.js" --exclude="*.gif" --exclude="*.png" --exclude="*.svg" --exclude="*.css" --exclude="*.html" --exclude="*.json" --exclude="sw.json" --delete public/ s3://${{ secrets.PRODUCTION_BUCKET_NAME }}/
84+
85+
- name: Invalidate cloudflare cache
86+
uses: nathanvaughn/actions-cloudflare-purge@master
87+
with:
88+
cf_zone: ${{ secrets.CLOUDFLARE_ZONE }}
89+
cf_auth: ${{ secrets.CLOUDFLARE_PURGE_API_TOKEN }}
90+
prefixes: https://docs.arduino.cc/resources/datasheets/

.github/workflows/deploy-staging.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,18 @@ jobs:
7272
aws-region: us-east-1
7373

7474
- name: Sync all cacheable assets
75-
run: aws s3 sync --cache-control "public, max-age=31536000, immutable" --include "*.css" --include="*.js" --include="*.gif" --include="*.png" --include="*.svg" --exclude "*.html" --exclude="sw.js" --exclude="*.json" --delete public/ s3://${{ secrets.STAGING_BUCKET_NAME }}/
75+
run: aws s3 sync --cache-control "public, max-age=31536000, immutable" --include "*.css" --include="*.js" --include="*.gif" --include="*.png" --include="*.svg" --exclude "*.html" --exclude="sw.js" --exclude="*.json" --exclude="*.pdf" --delete public/ s3://${{ secrets.STAGING_BUCKET_NAME }}/
7676

7777
- name: Sync all non-cacheable assets
7878
# Don't cache any HTML or JSON file: they should always be up-to-dates
79-
run: aws s3 sync --cache-control "public, max-age=0, must-revalidate" --include "*.html" --include="sw.js" --include="*.json" --include "*.css" --exclude="*.js" --exclude="*.gif" --exclude="*.png" --exclude="*.svg" --delete public/ s3://${{ secrets.STAGING_BUCKET_NAME }}/
79+
run: aws s3 sync --cache-control "public, max-age=0, must-revalidate" --include "*.html" --include="sw.js" --include="*.json" --include "*.css" --exclude="*.js" --exclude="*.gif" --exclude="*.png" --exclude="*.svg" --exclude="*.pdf" --delete public/ s3://${{ secrets.STAGING_BUCKET_NAME }}/
80+
81+
- name: Sync PDF
82+
run: aws s3 sync --cache-control "public, max-age=86400, must-revalidate" --include "*.pdf" --exclude="*.js" --exclude="*.gif" --exclude="*.png" --exclude="*.svg" --exclude="*.css" --exclude="*.html" --exclude="*.json" --exclude="sw.json" --delete public/ s3://${{ secrets.STAGING_BUCKET_NAME }}/
83+
84+
- name: Purge cache on CloudFlare
85+
run: |
86+
curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE }}/purge_cache" \
87+
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_PURGE_API_TOKEN }}" \
88+
-H "Content-Type: application/json" \
89+
--data '{"prefixes":["${{ vars.DATASHEETS_BASE_URL }}"]}'

0 commit comments

Comments
 (0)