-
-
Notifications
You must be signed in to change notification settings - Fork 400
135 lines (114 loc) · 3.95 KB
/
deploy-staging.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Deploy to docs-content.oniudra.cc
on:
workflow_dispatch:
push:
branches:
- ghaction
concurrency:
group: deploy-staging
cancel-in-progress: true
# Allow installation of dependencies
permissions:
id-token: write
contents: read
jobs:
# This job is used to render datasheets, but only if they have changed.
# It's a separate job so we don't have to cleanup the machine afterwards.
render-datasheets:
name: Render Datasheets
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v4
id: cache
with:
path: static/resources/datasheets
key: ${{ runner.os }}-datasheets-${{ hashFiles('**/*datasheet.md') }}
- uses: actions/checkout@v4
if: steps.cache.outputs.cache-hit != 'true'
with:
fetch-depth: 1
- uses: actions/setup-node@v4
if: steps.cache.outputs.cache-hit != 'true'
with:
node-version: 18
cache: "npm"
cache-dependency-path: "package-lock.json"
- name: Render Datasheets
if: steps.cache.outputs.cache-hit != 'true'
run: |
cd ${GITHUB_WORKSPACE}/scripts/datasheet-rendering
./render-datasheets.sh
cd $GITHUB_WORKSPACE
mkdir -p static/resources/datasheets
find ./content/hardware -type f -name "*-datasheet.pdf" -exec cp {} ./static/resources/datasheets/ \;
- name: Export artifact
uses: actions/upload-artifact@v4
with:
name: datasheets
path: static/resources/datasheets
retention-days: 1 # Only needed to pass it to the next job
build:
name: Build and Deploy
needs: render-datasheets
runs-on: ubuntu-latest
environment: staging
env:
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
APP_ENV: staging
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cleanup runner disk
uses: ./.github/actions/cleanup-disk # Cleanup machine before starting the build
- uses: actions/setup-node@v4
with:
node-version: 18
cache: "npm"
cache-dependency-path: "package-lock.json"
- uses: actions/download-artifact@v4
with:
name: datasheets
- name: Copy Static Files
run: |
mkdir -p static/resources/schematics static/resources/pinouts static/resources/models
find ./content/hardware -type f -name "*-full-pinout.pdf" -exec cp {} ./static/resources/pinouts/ \;
find ./content/hardware -type f -name "*-pinout.png" -exec cp {} ./static/resources/pinouts/ \;
find ./content/hardware -type f -name "*-step.zip" -exec cp {} ./static/resources/models/ \;
- name: Gatsby main cache
uses: actions/cache@v4
id: gatsby-cache-folder
with:
path: .cache
key: ${{ runner.os }}-cache-gatsby-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-cache-gatsby-main
- name: Gatsby Public Folder
uses: actions/cache@v4
id: gatsby-public-folder
with:
path: public/
key: ${{ runner.os }}-public-gatsby-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-public-gatsby-main
- run: npm install
- run: npm run build
- name: Clean up node_modules # Just to save space
run: rm -rf node_modules
- name: Deploy to S3
uses: ./.github/actions/sync-s3
with:
role-to-assume: ${{ secrets.STAGING_IAM_ROLE }}
bucket-name: ${{ secrets.STAGING_BUCKET_NAME }}
purge-datasheets:
name: Purge Datasheets cache
needs: build
runs-on: ubuntu-latest
environment: staging
steps:
- name: Invalidate datasheets cache
uses: ./.github/actions/cloudflare-purge
with:
api-token: ${{ secrets.CLOUDFLARE_PURGE_API_TOKEN }}
zone: ${{ secrets.CLOUDFLARE_ZONE }}
prefix: ${{ vars.DATASHEETS_BASE_URL }}