@@ -10,13 +10,30 @@ concurrency:
10
10
group : deploy-production
11
11
cancel-in-progress : true
12
12
13
+ # Allow installation of dependencies
13
14
permissions :
14
15
id-token : write
15
16
contents : read
16
17
17
18
jobs :
19
+ # This job is used to render datasheets, but only if they have changed.
20
+ # It's a separate job so we don't have to cleanup the machine afterwards.
21
+ render-datasheets :
22
+ name : Render Datasheets
23
+ runs-on : ubuntu-latest
24
+ steps :
25
+ - uses : actions/checkout@v4
26
+ with :
27
+ fetch-depth : 1
28
+
29
+ - uses : ./.github/actions/generate-datasheets
30
+ with :
31
+ artifact-name : datasheets
32
+ datasheets-path : static/resources/datasheets
33
+
18
34
build :
19
- if : " github.repository == 'arduino/docs-content'"
35
+ name : Build and Deploy
36
+ needs : render-datasheets
20
37
runs-on : ubuntu-latest
21
38
environment : production
22
39
env :
@@ -26,21 +43,29 @@ jobs:
26
43
steps :
27
44
- uses : actions/checkout@v4
28
45
with :
29
- fetch-depth : 0
46
+ fetch-depth : 1
47
+
48
+ - name : Cleanup runner disk
49
+ uses : ./.github/actions/cleanup-disk # Cleanup machine before starting the build
50
+
30
51
- uses : actions/setup-node@v4
31
52
with :
32
53
node-version : 18
33
54
cache : " npm"
34
- cache-dependency-path : " **/ package-lock.json"
55
+ cache-dependency-path : " package-lock.json"
35
56
36
- - name : Render Datasheets
37
- run : cd ${GITHUB_WORKSPACE}/scripts/datasheet-rendering;./render-datasheets.sh
57
+ - name : Retrieve Datasheets
58
+ uses : actions/download-artifact@v4 # Retrieve the datasheets generated in the previous job
59
+ with :
60
+ name : datasheets
61
+ path : static/resources/datasheets
62
+
63
+ - name : Debug datasheet list
64
+ run : ls -lah static/resources/datasheets
38
65
39
66
- name : Copy Static Files
40
67
run : |
41
- mkdir -p static/resources/datasheets static/resources/schematics static/resources/pinouts static/resources/models
42
- find ./content/hardware -type f -name "*-schematics.pdf" -exec cp {} ./static/resources/schematics/ \;
43
- find ./content/hardware -type f -name "*-datasheet.pdf" -exec cp {} ./static/resources/datasheets/ \;
68
+ mkdir -p static/resources/schematics static/resources/pinouts static/resources/models
44
69
find ./content/hardware -type f -name "*-full-pinout.pdf" -exec cp {} ./static/resources/pinouts/ \;
45
70
find ./content/hardware -type f -name "*-pinout.png" -exec cp {} ./static/resources/pinouts/ \;
46
71
find ./content/hardware -type f -name "*-step.zip" -exec cp {} ./static/resources/models/ \;
@@ -50,31 +75,43 @@ jobs:
50
75
id : gatsby-cache-folder
51
76
with :
52
77
path : .cache
53
- key : ${{ runner.os }}-cache-gatsby-${{ github.sha }}
78
+ key : ${{ runner.os }}-cache-gatsby-${{ github.ref_name }}
54
79
restore-keys : |
55
- ${{ runner.os }}-cache-gatsby-
80
+ ${{ runner.os }}-cache-gatsby-main
56
81
57
- - name : Gatsby Public Folder
82
+ - name : Gatsby Public Folder cache
58
83
uses : actions/cache@v4
59
84
id : gatsby-public-folder
60
85
with :
61
86
path : public/
62
- key : ${{ runner.os }}-public-gatsby-${{ github.sha }}
87
+ key : ${{ runner.os }}-public-gatsby-${{ github.ref_name }}
63
88
restore-keys : |
64
- ${{ runner.os }}-public-gatsby-
89
+ ${{ runner.os }}-public-gatsby-main
65
90
66
91
- run : npm install
92
+
67
93
- run : npm run build
68
94
69
- - name : Configure AWS credentials from Production account
70
- uses : aws-actions/configure-aws-credentials@v4
95
+ - name : Clean up node_modules # Just to save space
96
+ run : rm -rf node_modules
97
+
98
+ - name : Deploy to S3
99
+ uses : ./.github/actions/sync-s3
71
100
with :
72
101
role-to-assume : ${{ secrets.PRODUCTION_IAM_ROLE }}
73
- aws-region : us-east-1
74
-
75
- - 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 }}/
102
+ bucket-name : ${{ secrets.PRODUCTION_BUCKET_NAME }}
77
103
78
- - name : Sync all non-cacheable assets
79
- # 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 }}/
104
+ purge-datasheets :
105
+ name : Purge Datasheets cache
106
+ needs : build
107
+ runs-on : ubuntu-latest
108
+ environment : production
109
+ steps :
110
+ - name : Purge Cloudflare Cache
111
+ shell : bash
112
+ run : |
113
+ echo "Purging Cloudflare cache for prefix: ${{ vars.DATASHEETS_BASE_URL }}, zone: ${{ vars.CLOUDFLARE_ZONE }}"
114
+ curl -f -X POST "https://api.cloudflare.com/client/v4/zones/${{ vars.CLOUDFLARE_ZONE }}/purge_cache" \
115
+ -H "Authorization: Bearer ${{ secrets.CLOUDFLARE_PURGE_API_TOKEN }}" \
116
+ -H "Content-Type: application/json" \
117
+ --data '{"prefixes":["${{ vars.DATASHEETS_BASE_URL }}"]}'
0 commit comments