Skip to content

Commit bd72bae

Browse files
authored
Merge 11635c4 into 3e70f5f
2 parents 3e70f5f + 11635c4 commit bd72bae

File tree

3 files changed

+138
-62
lines changed

3 files changed

+138
-62
lines changed

Diff for: .github/workflows/cloudflare.yml

-61
This file was deleted.

Diff for: .github/workflows/preview.yml

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: Preview Deployment
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, labeled]
9+
10+
concurrency:
11+
group: netlify-${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
run:
16+
if: contains(github.event.pull_request.labels.*.name, 'preview') || ${{ github.ref_name == 'main' }}
17+
runs-on: ubuntu-latest
18+
concurrency:
19+
group: netlify
20+
cancel-in-progress: false
21+
env:
22+
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
23+
APP_ENV: prod
24+
BRANCH_NAME: ${{ github.ref_name }}
25+
26+
steps:
27+
28+
- name: Find PR Preview Comment
29+
if: github.event_name == 'pull_request'
30+
uses: peter-evans/find-comment@v1
31+
id: deploy-preview-comment
32+
with:
33+
issue-number: ${{ github.event.pull_request.number }}
34+
comment-author: "github-actions[bot]"
35+
body-includes: "Preview Deployment"
36+
37+
- name: Update Comment if exists
38+
if: github.event_name == 'pull_request' && steps.deploy-preview-comment.outputs.comment-id != 0
39+
uses: peter-evans/[email protected]
40+
with:
41+
comment-id: ${{ steps.deploy-preview-comment.outputs.comment-id }}
42+
edit-mode: replace
43+
body: |
44+
## Preview Deployment
45+
Waiting for deployment to complete...
46+
47+
- uses: actions/checkout@v4
48+
49+
- uses: actions/setup-node@v4
50+
with:
51+
node-version: 18
52+
cache: "npm"
53+
cache-dependency-path: "**/package-lock.json"
54+
55+
- name: Render Datasheets
56+
run: cd ${GITHUB_WORKSPACE}/scripts/datasheet-rendering;./render-datasheets.sh
57+
58+
- name: Copy Static Files
59+
run: |
60+
mkdir -p static/resources/datasheets static/resources/schematics static/resources/pinouts
61+
find ./content/hardware -type f -name "*-schematics.pdf" -exec cp {} ./static/resources/schematics/ \;
62+
find ./content/hardware -type f -name "*-datasheet.pdf" -exec cp {} ./static/resources/datasheets/ \;
63+
find ./content/hardware -type f -name "*-full-pinout.pdf" -exec cp {} ./static/resources/pinouts/ \;
64+
find ./content/hardware -type f -name "*-pinout.png" -exec cp {} ./static/resources/pinouts/ \;
65+
66+
- name: Gatsby main cache
67+
uses: actions/cache@v4
68+
id: gatsby-cache-folder
69+
with:
70+
path: .cache
71+
key: ${{ runner.os }}-cache-gatsby-${{ github.sha }}
72+
restore-keys: |
73+
${{ runner.os }}-cache-gatsby-
74+
75+
- name: Gatsby Public Folder
76+
uses: actions/cache@v4
77+
id: gatsby-public-folder
78+
with:
79+
path: public/
80+
key: ${{ runner.os }}-public-gatsby-${{ github.sha }}
81+
restore-keys: |
82+
${{ runner.os }}-public-gatsby-
83+
84+
- run: npm install
85+
- run: npm run build
86+
87+
- name: Install Netlify
88+
run: npm install [email protected] -g
89+
90+
- name: Deploy to Netlify Preview
91+
if: github.event_name == 'pull_request'
92+
run: |
93+
netlify deploy \
94+
--dir public \
95+
--site ${{ secrets.NETLIFY_SITE_ID }} \
96+
--auth ${{ secrets.NETLIFY_AUTH_TOKEN }} \
97+
--json \
98+
> deploy_output.json
99+
100+
- name: Deploy to Netlify Prod
101+
if: github.event_name != 'pull_request'
102+
run: |
103+
netlify deploy \
104+
--prod \
105+
--dir public \
106+
--site ${{ secrets.NETLIFY_SITE_ID }} \
107+
--auth ${{ secrets.NETLIFY_AUTH_TOKEN }} \
108+
--json \
109+
> deploy_output.json
110+
111+
- name: Generate URL Preview
112+
if: github.event_name == 'pull_request'
113+
id: url_preview
114+
run: |
115+
NETLIFY_PREVIEW_URL=$(jq -r '.deploy_url' deploy_output.json)
116+
echo "NETLIFY_PREVIEW_URL=$NETLIFY_PREVIEW_URL" >> "$GITHUB_OUTPUT"
117+
118+
- name: Create PR Preview Comment
119+
if: github.event_name == 'pull_request' && steps.deploy-preview-comment.outputs.comment-id == 0
120+
uses: peter-evans/[email protected]
121+
with:
122+
issue-number: ${{ github.event.pull_request.number }}
123+
body: |
124+
## Preview Deployment
125+
🚀 Preview this PR: ${{ steps.url_preview.outputs.NETLIFY_PREVIEW_URL }}
126+
📍 Commit SHA: ${{ github.sha }}
127+
128+
- name: Update PR Preview Comment
129+
if: github.event_name == 'pull_request' && steps.deploy-preview-comment.outputs.comment-id != 0
130+
uses: peter-evans/[email protected]
131+
with:
132+
comment-id: ${{ steps.deploy-preview-comment.outputs.comment-id }}
133+
edit-mode: replace
134+
body: |
135+
## Preview Deployment
136+
🚀 Preview this PR: ${{ steps.url_preview.outputs.NETLIFY_PREVIEW_URL }}
137+
📍 Commit SHA: ${{ github.sha }}

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Broken URLs will show an error alert. URL must be in the GitHub domain and must
9494

9595
## Previewing Changes
9696

97-
Whenever you create a Pull Request (PR) GatsbyCloud will create a preview deployment in which you can see how your changes look when rendered on the website. The link to the preview will appear in the comments of the PR. This also works with Draft PRs, but not for PRs created from a fork.
97+
Whenever you create a Pull Request (PR) and the label `preview` is assigned to it, a preview is created and updated for every commit, as explained at: https://github.com/arduino/docs-content/pull/1931
9898

9999
## License
100100

0 commit comments

Comments
 (0)