Skip to content

Commit 058110f

Browse files
committed
manual action for purge cache
1 parent 025b8ef commit 058110f

File tree

3 files changed

+116
-38
lines changed

3 files changed

+116
-38
lines changed

.github/workflows/deploy-production.yml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
steps:
2727
- uses: actions/checkout@v4
2828
with:
29-
fetch-depth: 0
29+
fetch-depth: 1
3030
- uses: actions/setup-node@v4
3131
with:
3232
node-version: 18
@@ -82,21 +82,19 @@ jobs:
8282
# Don't cache any HTML or JSON file: they should always be up-to-dates
8383
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 }}/
8484

85-
- name: Create temporary directory
86-
run: mkdir -p /tmp/aws-sync-temp
85+
# - name: Sync PDF
86+
# 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 }}/
8787

88-
- name: Copy files to temporary directory
89-
run: cp -r public/*.pdf /tmp/aws-sync-temp/
88+
# - name: Purge cache on CloudFlare
89+
# run: |
90+
# curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE }}/purge_cache" \
91+
# -H "Authorization: Bearer ${{ secrets.CLOUDFLARE_PURGE_API_TOKEN }}" \
92+
# -H "Content-Type: application/json" \
93+
# --data '{"prefixes":["${{ vars.DATASHEETS_BASE_URL }}"]}'
9094

91-
- name: Sync PDF
92-
run: aws s3 sync --cache-control "public, max-age=86400, must-revalidate" /tmp/aws-sync-temp/ s3://${{ secrets.PRODUCTION_BUCKET_NAME }}/ --exclude "*.js" --exclude "*.gif" --exclude "*.png" --exclude "*.svg" --exclude "*.css" --exclude "*.html" --exclude "*.json" --exclude "sw.json" --delete
93-
94-
- name: Cleanup temporary files
95-
run: rm -rf /tmp/aws-sync-temp
95+
- name: Sync all cacheable assets
96+
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 }}/
9697

97-
- name: Purge cache on CloudFlare
98-
run: |
99-
curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE }}/purge_cache" \
100-
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_PURGE_API_TOKEN }}" \
101-
-H "Content-Type: application/json" \
102-
--data '{"prefixes":["${{ vars.DATASHEETS_BASE_URL }}"]}'
98+
- name: Sync all non-cacheable assets
99+
# Don't cache any HTML or JSON file: they should always be up-to-dates
100+
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 }}/

.github/workflows/deploy-staging.yml

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
steps:
2626
- uses: actions/checkout@v4
2727
with:
28-
fetch-depth: 0
28+
fetch-depth: 1
2929
- uses: actions/setup-node@v4
3030
with:
3131
node-version: 18
@@ -74,29 +74,26 @@ jobs:
7474
role-to-assume: ${{ secrets.STAGING_IAM_ROLE }}
7575
aws-region: us-east-1
7676

77-
- name: Sync all cacheable assets
78-
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 }}/
79-
80-
- name: Sync all non-cacheable assets
81-
# Don't cache any HTML or JSON file: they should always be up-to-dates
82-
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 }}/
83-
84-
- name: Create temporary directory
85-
run: mkdir -p /tmp/aws-sync-temp
77+
# - name: Sync all cacheable assets
78+
# 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 }}/
8679

87-
- name: Copy files to temporary directory
88-
run: cp -r public/*.pdf /tmp/aws-sync-temp/
80+
# - name: Sync all non-cacheable assets
81+
# # Don't cache any HTML or JSON file: they should always be up-to-dates
82+
# 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 }}/
8983

90-
- name: Sync PDF
91-
run: aws s3 sync --cache-control "public, max-age=86400, must-revalidate" /tmp/aws-sync-temp/ s3://${{ secrets.STAGING_BUCKET_NAME }}/ --exclude "*.js" --exclude "*.gif" --exclude "*.png" --exclude "*.svg" --exclude "*.css" --exclude "*.html" --exclude "*.json" --exclude "sw.json" --delete
84+
# - name: Sync PDF
85+
# 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 }}/
9286

93-
- name: Cleanup temporary files
94-
run: rm -rf /tmp/aws-sync-temp
87+
# - name: Purge cache on CloudFlare
88+
# run: |
89+
# curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE }}/purge_cache" \
90+
# -H "Authorization: Bearer ${{ secrets.CLOUDFLARE_PURGE_API_TOKEN }}" \
91+
# -H "Content-Type: application/json" \
92+
# --data '{"prefixes":["${{ vars.DATASHEETS_BASE_URL }}"]}'
9593

96-
- name: Purge cache on CloudFlare
97-
run: |
98-
curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE }}/purge_cache" \
99-
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_PURGE_API_TOKEN }}" \
100-
-H "Content-Type: application/json" \
101-
--data '{"prefixes":["${{ vars.DATASHEETS_BASE_URL }}"]}'
94+
- name: Sync all cacheable assets
95+
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 }}/
10296

97+
- name: Sync all non-cacheable assets
98+
# Don't cache any HTML or JSON file: they should always be up-to-dates
99+
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 }}/

.github/workflows/purge-cache.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Purge cache on CloudFlare
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
id-token: write
8+
contents: read
9+
10+
jobs:
11+
purge:
12+
if: "github.repository == 'arduino/docs-content'"
13+
runs-on: ubuntu-latest
14+
environment: production
15+
env:
16+
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
17+
APP_ENV: prod
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: 18
26+
cache: "npm"
27+
cache-dependency-path: "**/package-lock.json"
28+
29+
- name: Render Datasheets
30+
run: cd ${GITHUB_WORKSPACE}/scripts/datasheet-rendering;./render-datasheets.sh
31+
32+
- name: Copy Static Files
33+
run: |
34+
mkdir -p static/resources/datasheets static/resources/schematics static/resources/pinouts static/resources/models
35+
find ./content/hardware -type f -name "*-schematics.pdf" -exec cp {} ./static/resources/schematics/ \;
36+
find ./content/hardware -type f -name "*-datasheet.pdf" -exec cp {} ./static/resources/datasheets/ \;
37+
find ./content/hardware -type f -name "*-full-pinout.pdf" -exec cp {} ./static/resources/pinouts/ \;
38+
find ./content/hardware -type f -name "*-pinout.png" -exec cp {} ./static/resources/pinouts/ \;
39+
find ./content/hardware -type f -name "*-step.zip" -exec cp {} ./static/resources/models/ \;
40+
41+
- name: Gatsby main cache
42+
uses: actions/cache@v4
43+
id: gatsby-cache-folder
44+
with:
45+
path: .cache
46+
key: ${{ runner.os }}-cache-gatsby-${{ github.ref_name }}
47+
restore-keys: |
48+
${{ runner.os }}-cache-gatsby-main
49+
50+
- name: Gatsby Public Folder
51+
uses: actions/cache@v4
52+
id: gatsby-public-folder
53+
with:
54+
path: public/
55+
key: ${{ runner.os }}-public-gatsby-${{ github.ref_name }}
56+
restore-keys: |
57+
${{ runner.os }}-public-gatsby-main
58+
59+
- run: npm install
60+
- run: npm run build
61+
62+
- name: Configure AWS credentials from Production account
63+
uses: aws-actions/configure-aws-credentials@v4
64+
with:
65+
role-to-assume: ${{ secrets.PRODUCTION_IAM_ROLE }}
66+
aws-region: us-east-1
67+
68+
- name: Sync all cacheable assets
69+
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 }}/
70+
71+
- name: Sync all non-cacheable assets
72+
# Don't cache any HTML or JSON file: they should always be up-to-dates
73+
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 }}/
74+
75+
- name: Sync PDF
76+
run: aws s3 sync --cache-control "public, max-age=86400, must-revalidate" /tmp/aws-sync-temp/ s3://${{ secrets.PRODUCTION_BUCKET_NAME }}/ --exclude "*.js" --exclude "*.gif" --exclude "*.png" --exclude "*.svg" --exclude "*.css" --exclude "*.html" --exclude "*.json" --exclude "sw.json" --delete
77+
78+
- name: Purge cache on CloudFlare
79+
run: |
80+
curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE }}/purge_cache" \
81+
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_PURGE_API_TOKEN }}" \
82+
-H "Content-Type: application/json" \
83+
--data '{"prefixes":["${{ vars.DATASHEETS_BASE_URL }}"]}'

0 commit comments

Comments
 (0)