Skip to content

Commit 81bbd1e

Browse files
authored
feat: github action to integrate/publish endo and agoric-sdk reference docs too (#1038)
* feat: github action to integrate/publish endo reference doc too * feat: refine build steps and add steps to build agoric-sdk docs * debug: add `yarn build` like Dan suggested * chore: bump vitepress to 1.0.1 * debug: add a DEBUG flag to "docs:build-cf" script * chore: update ignoreDeadLinks list * ci: update yarn commands to generate markdown files * ci: update github workflow to reflect upstream changes * ci: use cloudflare/pages-action instead and add a step to comment URL * ci: switch back to using wrangler-action and use its output * ci: add a condition to check if event is pull request * ci: add conditions for preview and production deployments separately * comment: add some background in comments for build-deploy-doc workflow * chore: add endo and agoric-sdk to submodules * ci: disable github workflow for now * chore: bump node version to 18.18.0 * ci: add several yarn targets to build .md docs for endo and agoric-sdk * chore: update submodules * chore: add a yarn target for `git:update-submodules` * debug: undo `yarn install` by cloudflare to build * debug: update file paths when `mv`ing * chore: add a comment for docs:build-cf script * chore: add a yarn script for git-submodule:init
1 parent d50c4e9 commit 81bbd1e

File tree

8 files changed

+489
-434
lines changed

8 files changed

+489
-434
lines changed
Lines changed: 71 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,86 @@
1-
# Based on example at: https://github.com/marketplace/actions/deploy-to-github-pages
2-
31
name: Build and Deploy documentation site
2+
3+
# This workflow is a customized workflow to deploy docs site to Cloudflare
4+
# The reason we can no longer use Cloudflare's git integration to deploy docs
5+
# site anymore is that Cloudflare's git integration would only check out
6+
# documentation repo, whereas we need to check out both `endojs/endo` and
7+
# `agoric/agoric-sdk` repo to build the docs site.
8+
49
on:
5-
push:
6-
branches:
10+
# If it's a push to production branch, Cloudflare wrangler will deploy it as a
11+
# production deployment
12+
# The production branch for documentation project on Cloudflare is configured
13+
# to be `main`
14+
push:
15+
branches:
716
- main
17+
# If it's a push to a non-production branch, Cloudflare wrangler will deploy
18+
# it as a preview deployment
19+
pull_request:
20+
branches:
21+
- "*"
22+
823
jobs:
924
build-and-deploy:
1025
runs-on: ubuntu-latest
1126
steps:
1227
- name: Checkout
13-
uses: actions/[email protected]
28+
uses: actions/checkout@v4
29+
30+
- name: Checkout Endo
31+
uses: actions/checkout@v4
32+
with:
33+
repository: endojs/endo
34+
path: endo
35+
36+
- name: Build Endo docs
37+
run: |
38+
cd endo
39+
yarn install
40+
yarn docs:markdown-for-agoric-documentation-repo
41+
42+
- name: Move Endo docs into main/reference
43+
run: mv endo/api-docs main/reference/endo
44+
45+
- name: Checkout agoric-sdk
46+
uses: actions/checkout@v4
1447
with:
15-
persist-credentials: false
48+
repository: agoric/agoric-sdk
49+
path: agoric-sdk
1650

17-
- name: Install and Build
51+
- name: Build agoric-sdk docs
1852
run: |
53+
cd agoric-sdk
1954
yarn install
20-
yarn docs:build
55+
yarn build
56+
yarn docs:markdown-for-agoric-documentation-repo
57+
58+
- name: Move agoric-sdk docs into main/reference
59+
run: mv agoric-sdk/api-docs main/reference/agoric-sdk
2160

22-
- name: Configure SSH
61+
- name: Build Doc site
2362
run: |
24-
mkdir -m0700 -p ~/.ssh/
25-
echo "$SSH_KEY" > ~/.ssh/staging.key
26-
chmod 600 ~/.ssh/staging.key
27-
cat >>~/.ssh/config <<END
28-
Host staging
29-
HostName $SSH_HOST
30-
User $SSH_USER
31-
IdentityFile ~/.ssh/staging.key
32-
StrictHostKeyChecking no
33-
Host staging2
34-
HostName $SSH_HOST2
35-
User $SSH_USER
36-
IdentityFile ~/.ssh/staging.key
37-
StrictHostKeyChecking no
38-
END
39-
env:
40-
SSH_USER: ${{ secrets.STAGING_SSH_USER }}
41-
SSH_KEY: ${{ secrets.STAGING_SSH_KEY }}
42-
SSH_HOST: ${{ secrets.STAGING_SSH_HOST }}
43-
SSH_HOST2: ${{ secrets.STAGING_SSH_HOST2 }}
44-
45-
- name: SSH check out and build (staging)
46-
run: ssh staging 'cd documentation && git pull && yarn install --frozen-lockfile && yarn docs:build'
47-
48-
- name: SSH check out and build (staging2)
49-
run: ssh staging2 'cd documentation && git pull && yarn install --frozen-lockfile && yarn docs:build'
50-
51-
- name: Deploy to gh-pages
52-
uses: JamesIves/[email protected]
63+
yarn install
64+
yarn docs:build-cf
65+
66+
- name: Publish to Cloudflare Pages
67+
id: publish-to-cloudflare-pages
68+
uses: cloudflare/wrangler-action@v3
69+
with:
70+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
71+
# Cloudflare account ID is safe to be public
72+
# Ref: https://github.com/cloudflare/wrangler-legacy/issues/209#issuecomment-541654484
73+
accountId: 0c4635effffcd7f36d1b9f0425a4367a
74+
command: pages deploy --project-name=documentation dist/
75+
76+
- name: Comment with preview URL
77+
if: github.event_name == 'pull_request'
78+
uses: actions/github-script@v7
5379
with:
54-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Provided by github: https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#about-the-github_token-secret
55-
BRANCH: gh-pages # The branch the action should deploy to.
56-
FOLDER: main/.vitepress/dist # The folder the action should deploy
57-
CLEAN: true # Automatically remove deleted files from the deploy branch
80+
script: |
81+
github.rest.issues.createComment({
82+
issue_number: context.issue.number,
83+
owner: context.repo.owner,
84+
repo: context.repo.repo,
85+
body: 'Cloudflare Pages Preview URL: ${{ steps.publish-to-cloudflare-pages.outputs.deployment-url }}'
86+
})

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "agoric-sdk"]
2+
path = agoric-sdk
3+
url = https://github.com/Agoric/agoric-sdk
4+
[submodule "endo"]
5+
path = endo
6+
url = https://github.com/endojs/endo

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.17.0
1+
v18.18.0

agoric-sdk

Submodule agoric-sdk added at 03b6420

endo

Submodule endo added at c8c99bf

main/.vitepress/config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ export default defineConfig({
8383
ignoreDeadLinks: [
8484
// ignore all localhost links
8585
/^https?:\/\/localhost/,
86+
// ignore links that starts with ./packages/*
87+
/^.\/packages\/*/,
88+
'./MAINTAINERS',
89+
'./CONTRIBUTING',
90+
'./LICENSE',
8691
],
8792
sitemap: {
8893
hostname: 'https://docs.agoric.com',

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
"docs:dev": "NODE_OPTIONS=--openssl-legacy-provider vitepress dev main",
88
"docs:build": "NODE_OPTIONS=--openssl-legacy-provider vitepress build main",
99
"docs:preview": "NODE_OPTIONS=--openssl-legacy-provider vitepress preview main",
10-
"docs:build-cf": "NODE_OPTIONS=--openssl-legacy-provider vitepress build main && cp _redirects dist/",
10+
"docs:build-endo": "cd endo; yarn install; yarn docs:markdown-for-agoric-documentation-repo; mv api-docs ../main/reference/endo",
11+
"docs:build-agoric-sdk": "cd agoric-sdk; yarn install; yarn build; yarn docs:markdown-for-agoric-documentation-repo; mv api-docs ../main/reference/agoric-sdk",
12+
"//docs:build-cf": "echo 'XXX Cloudflare Pages deployment will automatically run `yarn install` right after `git clone`, but this will interfere with building markdown files for endo and agoric-sdk. So we remove node_modules directory before building markdown files and run `yarn install` before running vitepress'",
13+
"docs:build-cf": "rm -rf node_modules; yarn docs:build-endo; yarn docs:build-agoric-sdk; yarn install; DEBUG='vitepress:*' NODE_OPTIONS=--openssl-legacy-provider vitepress build main && cp _redirects dist/",
14+
"git-submodule:init": "git submodule init",
15+
"git-submodule:update": "git submodule update --remote --merge",
1116
"test": "ava",
1217
"lint-fix": "yarn lint --fix",
1318
"lint": "eslint 'snippets/**/*.js'",
@@ -65,7 +70,7 @@
6570
"prettier": "^1.19.1",
6671
"ses": "^0.18.8",
6772
"stylus": "^0.62.0",
68-
"vitepress": "^1.0.0-rc.42"
73+
"vitepress": "^1.0.1"
6974
},
7075
"resolutions": {},
7176
"globals": {

0 commit comments

Comments
 (0)