Skip to content

Commit 7d56189

Browse files
committed
Merge branch 'main' into sync/mcmchris/opta-digital-exp/datasheet-update
2 parents 838a3f5 + 4c92470 commit 7d56189

File tree

1,203 files changed

+21916
-4335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,203 files changed

+21916
-4335
lines changed
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Disk cleanup
2+
description: "Cleanup disk space"
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Free up disk space
7+
shell: bash
8+
run: |
9+
echo "Disk space before cleanup..."
10+
df -h /
11+
echo "Removing unnecessary files to free up disk space..."
12+
# https://github.com/actions/runner-images/issues/2840#issuecomment-2272410832
13+
sudo rm -rf \
14+
/opt/hostedtoolcache \
15+
/opt/google/chrome \
16+
/opt/microsoft/msedge \
17+
/opt/microsoft/powershell \
18+
/opt/pipx \
19+
/usr/lib/mono \
20+
/usr/local/julia* \
21+
/usr/local/lib/android \
22+
/usr/local/lib/node_modules \
23+
/usr/local/share/chromium \
24+
/usr/local/share/powershell \
25+
/usr/share/dotnet \
26+
/usr/share/swift
27+
echo "Disk space after cleanup..."
28+
df -h /

.github/actions/cloudflare-upload/action.yml

-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ inputs:
2020
runs:
2121
using: composite
2222
steps:
23-
2423
- name: Find PR Preview Comment
2524
if: github.event_name == 'pull_request'
2625
uses: peter-evans/find-comment@v1
@@ -67,7 +66,6 @@ runs:
6766
🚀 Preview this PR: ${{ steps.deploy-cloudflare.outputs.url }}
6867
📍 Commit SHA: ${{ github.sha }}
6968
70-
7169
- name: Update PR Preview Comment
7270
if: github.event_name == 'pull_request' && steps.deploy-preview-comment.outputs.comment-id != 0
7371
uses: peter-evans/[email protected]
@@ -78,4 +76,3 @@ runs:
7876
### ${{ inputs.project-name }}
7977
🚀 Preview this PR: ${{ steps.deploy-cloudflare.outputs.url }}
8078
📍 Commit SHA: ${{ github.sha }}
81-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: "Generate Datasheets"
2+
description: "Generate product datasheets from markdown files"
3+
inputs:
4+
datasheets-path:
5+
description: "The datasheets path"
6+
required: true
7+
default: static/resources/datasheets
8+
artifact-name:
9+
description: "The name of the output artifact"
10+
required: true
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- uses: actions/cache@v4
16+
id: cache
17+
with:
18+
path: ${{ inputs.datasheets-path }}
19+
key: ${{ runner.os }}-datasheets-${{ hashFiles('**/*datasheet.md') }}
20+
21+
- uses: actions/setup-node@v4
22+
if: steps.cache.outputs.cache-hit != 'true'
23+
with:
24+
node-version: 18
25+
cache: "npm"
26+
cache-dependency-path: "package-lock.json"
27+
28+
- name: Render Datasheets
29+
if: steps.cache.outputs.cache-hit != 'true'
30+
run: |
31+
cd ${GITHUB_WORKSPACE}/scripts/datasheet-rendering
32+
./render-datasheets.sh
33+
cd $GITHUB_WORKSPACE
34+
mkdir -p ${{ inputs.datasheets-path }}
35+
find ./content/hardware -type f -name "*-datasheet.pdf" -exec cp {} ./${{ inputs.datasheets-path }}/ \;
36+
shell: bash
37+
38+
- name: Export artifact
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: ${{ inputs.artifact-name }}
42+
path: ${{ inputs.datasheets-path }}
43+
retention-days: 1 # Only needed to pass it to the next job

.github/actions/sync-s3/action.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Sync assets on S3
2+
description: "Sync Docs assets on S3"
3+
inputs:
4+
role-to-assume:
5+
description: "The IAM role to assume"
6+
required: true
7+
bucket-name:
8+
description: "The name of the S3 bucket to sync assets to"
9+
required: true
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Configure AWS credentials from Staging account
14+
uses: aws-actions/configure-aws-credentials@v4
15+
with:
16+
role-to-assume: ${{ inputs.role-to-assume }}
17+
aws-region: us-east-1
18+
19+
- name: Sync all cacheable assets
20+
shell: bash
21+
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://${{ inputs.bucket-name }}/
22+
23+
- name: Sync all non-cacheable assets
24+
shell: bash
25+
# Don't cache any HTML or JSON file: they should always be up-to-dates
26+
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://${{ inputs.bucket-name }}/
27+
28+
- name: Sync PDF
29+
shell: bash
30+
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://${{ inputs.bucket-name }}/

.github/workflows/deploy-prd.yml

-75
This file was deleted.
+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Deploy to docs-content.arduino.cc
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
concurrency:
10+
group: deploy-production
11+
cancel-in-progress: true
12+
13+
# Allow installation of dependencies
14+
permissions:
15+
id-token: write
16+
contents: read
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+
34+
build:
35+
name: Build and Deploy
36+
needs: render-datasheets
37+
runs-on: ubuntu-latest
38+
environment: production
39+
env:
40+
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
41+
APP_ENV: prod
42+
43+
steps:
44+
- uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 1
47+
48+
- name: Cleanup runner disk
49+
uses: ./.github/actions/cleanup-disk # Cleanup machine before starting the build
50+
51+
- uses: actions/setup-node@v4
52+
with:
53+
node-version: 18
54+
cache: "npm"
55+
cache-dependency-path: "package-lock.json"
56+
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
65+
66+
- name: Copy Static Files
67+
run: |
68+
mkdir -p static/resources/schematics static/resources/pinouts static/resources/models
69+
find ./content/hardware -type f -name "*-full-pinout.pdf" -exec cp {} ./static/resources/pinouts/ \;
70+
find ./content/hardware -type f -name "*-pinout.png" -exec cp {} ./static/resources/pinouts/ \;
71+
find ./content/hardware -type f -name "*-step.zip" -exec cp {} ./static/resources/models/ \;
72+
73+
- name: Gatsby main cache
74+
uses: actions/cache@v4
75+
id: gatsby-cache-folder
76+
with:
77+
path: .cache
78+
key: ${{ runner.os }}-cache-gatsby-${{ github.ref_name }}
79+
restore-keys: |
80+
${{ runner.os }}-cache-gatsby-main
81+
82+
- name: Gatsby Public Folder cache
83+
uses: actions/cache@v4
84+
id: gatsby-public-folder
85+
with:
86+
path: public/
87+
key: ${{ runner.os }}-public-gatsby-${{ github.ref_name }}
88+
restore-keys: |
89+
${{ runner.os }}-public-gatsby-main
90+
91+
- run: npm install
92+
93+
- run: npm run build
94+
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
100+
with:
101+
role-to-assume: ${{ secrets.PRODUCTION_IAM_ROLE }}
102+
bucket-name: ${{ secrets.PRODUCTION_BUCKET_NAME }}
103+
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

Comments
 (0)