Skip to content

Commit 4ea362b

Browse files
authored
Add plumbing to upload schemas to GitHub Pages every day (SchemaStore#4727)
1 parent 187ec0c commit 4ea362b

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

.github/workflows/github-pages.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: 'Deploy to GitHub pages'
2+
3+
on:
4+
schedule:
5+
# Every day at 20:30 UTC.
6+
- cron: '30 20 * * *'
7+
push:
8+
branches: ['master']
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: 'read'
13+
pages: 'write'
14+
id-token: 'write'
15+
16+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
17+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
18+
concurrency:
19+
group: 'pages'
20+
cancel-in-progress: false
21+
22+
jobs:
23+
# Build job.
24+
build:
25+
runs-on: 'ubuntu-latest'
26+
steps:
27+
- uses: 'actions/checkout@v4'
28+
- run: 'node ./cli.js build-website'
29+
- uses: 'actions/configure-pages@v5'
30+
- uses: 'actions/upload-pages-artifact@v3'
31+
with:
32+
path: './website'
33+
34+
# Deployment job.
35+
deploy:
36+
environment:
37+
name: 'github-pages'
38+
url: '${{ steps.deployment.outputs.page_url }}'
39+
runs-on: 'ubuntu-latest'
40+
needs: 'build'
41+
steps:
42+
- id: 'deployment'
43+
uses: 'actions/deploy-pages@v4'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This ignore file is shared with Prettier. It seems .git/ must be ignored manually now.
22
.git/
33

4+
website/
45
# registry API folder
56
src/api/registry/
67

cli.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,34 @@ async function taskMaintenance() {
908908
// await printDowngradableSchemaVersions()
909909
}
910910

911+
async function taskBuildWebsite() {
912+
await fs.mkdir('./website', { recursive: true })
913+
await Promise.all(
914+
SchemasToBeTested.map((schemaName) => {
915+
return fs
916+
.copyFile(
917+
path.join(SchemaDir, schemaName),
918+
path.join('./website', schemaName),
919+
)
920+
.catch((err) => {
921+
if (err.code !== 'EISDIR') throw err
922+
})
923+
}),
924+
)
925+
await Promise.all(
926+
SchemasToBeTested.map((schemaName) => {
927+
return fs
928+
.copyFile(
929+
path.join(SchemaDir, schemaName),
930+
path.join('./website', path.parse(schemaName).name),
931+
)
932+
.catch((err) => {
933+
if (err.code !== 'EISDIR') throw err
934+
})
935+
}),
936+
)
937+
}
938+
911939
async function assertFileSystemIsValid() {
912940
/**
913941
* Check that files exist only where files belong, and directories exist only
@@ -1858,6 +1886,7 @@ EXAMPLES:
18581886
'check-remote': taskCheckRemote,
18591887
report: taskReport,
18601888
maintenance: taskMaintenance,
1889+
'build-website': taskBuildWebsite,
18611890
'build-xregistry': taskBuildXRegistry,
18621891
build: taskCheck, // Undocumented alias.
18631892
}

0 commit comments

Comments
 (0)