Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: github action to integrate/publish endo and agoric-sdk reference docs too #1038

Merged
merged 24 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
649e426
feat: github action to integrate/publish endo reference doc too
LuqiPan Mar 26, 2024
e806103
feat: refine build steps and add steps to build agoric-sdk docs
LuqiPan Mar 26, 2024
9544c91
Merge branch 'main' into 927-reference-docs-in-search
LuqiPan Mar 26, 2024
3da9eca
debug: add `yarn build` like Dan suggested
LuqiPan Mar 26, 2024
162d794
chore: bump vitepress to 1.0.1
LuqiPan Mar 26, 2024
293db4e
debug: add a DEBUG flag to "docs:build-cf" script
LuqiPan Mar 26, 2024
9c85876
chore: update ignoreDeadLinks list
LuqiPan Mar 26, 2024
deb67f6
ci: update yarn commands to generate markdown files
LuqiPan Mar 26, 2024
56a16bb
ci: update github workflow to reflect upstream changes
LuqiPan Mar 27, 2024
50f3e25
ci: use cloudflare/pages-action instead and add a step to comment URL
LuqiPan Mar 27, 2024
b16111d
ci: switch back to using wrangler-action and use its output
LuqiPan Mar 27, 2024
f64b764
ci: add a condition to check if event is pull request
LuqiPan Mar 27, 2024
40d3697
ci: add conditions for preview and production deployments separately
LuqiPan Mar 27, 2024
059336b
comment: add some background in comments for build-deploy-doc workflow
LuqiPan Mar 27, 2024
2885469
chore: add endo and agoric-sdk to submodules
LuqiPan Apr 1, 2024
a1e4a9b
ci: disable github workflow for now
LuqiPan Apr 1, 2024
2f3993b
chore: bump node version to 18.18.0
LuqiPan Apr 1, 2024
9cdca18
ci: add several yarn targets to build .md docs for endo and agoric-sdk
LuqiPan Apr 1, 2024
57ac64e
chore: update submodules
LuqiPan Apr 1, 2024
b7ca228
chore: add a yarn target for `git:update-submodules`
LuqiPan Apr 1, 2024
891494f
debug: undo `yarn install` by cloudflare to build
LuqiPan Apr 1, 2024
a4284c5
debug: update file paths when `mv`ing
LuqiPan Apr 1, 2024
c813781
chore: add a comment for docs:build-cf script
LuqiPan Apr 1, 2024
ba4232f
chore: add a yarn script for git-submodule:init
LuqiPan Apr 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 71 additions & 42 deletions .github/workflows/build-deploy-doc.yml.DISABLED
Original file line number Diff line number Diff line change
@@ -1,57 +1,86 @@
# Based on example at: https://github.com/marketplace/actions/deploy-to-github-pages

name: Build and Deploy documentation site

# This workflow is a customized workflow to deploy docs site to Cloudflare
# The reason we can no longer use Cloudflare's git integration to deploy docs
# site anymore is that Cloudflare's git integration would only check out
# documentation repo, whereas we need to check out both `endojs/endo` and
# `agoric/agoric-sdk` repo to build the docs site.

on:
push:
branches:
# If it's a push to production branch, Cloudflare wrangler will deploy it as a
# production deployment
# The production branch for documentation project on Cloudflare is configured
# to be `main`
push:
branches:
- main
# If it's a push to a non-production branch, Cloudflare wrangler will deploy
# it as a preview deployment
pull_request:
branches:
- "*"

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.1
uses: actions/checkout@v4

- name: Checkout Endo
uses: actions/checkout@v4
with:
repository: endojs/endo
path: endo

- name: Build Endo docs
run: |
cd endo
yarn install
yarn docs:markdown-for-agoric-documentation-repo

- name: Move Endo docs into main/reference
run: mv endo/api-docs main/reference/endo

- name: Checkout agoric-sdk
uses: actions/checkout@v4
with:
persist-credentials: false
repository: agoric/agoric-sdk
path: agoric-sdk

- name: Install and Build
- name: Build agoric-sdk docs
run: |
cd agoric-sdk
yarn install
yarn docs:build
yarn build
yarn docs:markdown-for-agoric-documentation-repo

- name: Move agoric-sdk docs into main/reference
run: mv agoric-sdk/api-docs main/reference/agoric-sdk

- name: Configure SSH
- name: Build Doc site
run: |
mkdir -m0700 -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/staging.key
chmod 600 ~/.ssh/staging.key
cat >>~/.ssh/config <<END
Host staging
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/staging.key
StrictHostKeyChecking no
Host staging2
HostName $SSH_HOST2
User $SSH_USER
IdentityFile ~/.ssh/staging.key
StrictHostKeyChecking no
END
env:
SSH_USER: ${{ secrets.STAGING_SSH_USER }}
SSH_KEY: ${{ secrets.STAGING_SSH_KEY }}
SSH_HOST: ${{ secrets.STAGING_SSH_HOST }}
SSH_HOST2: ${{ secrets.STAGING_SSH_HOST2 }}

- name: SSH check out and build (staging)
run: ssh staging 'cd documentation && git pull && yarn install --frozen-lockfile && yarn docs:build'

- name: SSH check out and build (staging2)
run: ssh staging2 'cd documentation && git pull && yarn install --frozen-lockfile && yarn docs:build'

- name: Deploy to gh-pages
uses: JamesIves/github-pages-deploy-action@3.7.1
yarn install
yarn docs:build-cf

- name: Publish to Cloudflare Pages
id: publish-to-cloudflare-pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
# Cloudflare account ID is safe to be public
# Ref: https://github.com/cloudflare/wrangler-legacy/issues/209#issuecomment-541654484
accountId: 0c4635effffcd7f36d1b9f0425a4367a
command: pages deploy --project-name=documentation dist/

- name: Comment with preview URL
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
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
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: main/.vitepress/dist # The folder the action should deploy
CLEAN: true # Automatically remove deleted files from the deploy branch
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Cloudflare Pages Preview URL: ${{ steps.publish-to-cloudflare-pages.outputs.deployment-url }}'
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a supported option to get a link based on a branch? one where the content is updated as commits are added to the branch, without changing the url

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not with wrangler-action: https://github.com/cloudflare/wrangler-action/blob/fd98a7c99091f581101a9a9bc7300a005d2f63e7/action.yml#L48-L53

Cloudflare Page bot is working again though so we retain the branch preview URL behavior

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. .DISABLED

6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "agoric-sdk"]
path = agoric-sdk
url = https://github.com/Agoric/agoric-sdk
[submodule "endo"]
path = endo
url = https://github.com/endojs/endo
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.17.0
v18.18.0
1 change: 1 addition & 0 deletions agoric-sdk
Submodule agoric-sdk added at 03b642
1 change: 1 addition & 0 deletions endo
Submodule endo added at c8c99b
5 changes: 5 additions & 0 deletions main/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ export default defineConfig({
ignoreDeadLinks: [
// ignore all localhost links
/^https?:\/\/localhost/,
// ignore links that starts with ./packages/*
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the .md files generated from endo and agoric-sdk repo use these links below, which will fail the vitepress build as they're indeed dead links. There are 8 total offenders so it's not widespread, and I'm adding all of them here so they can be ignored by vitepress

/^.\/packages\/*/,
'./MAINTAINERS',
'./CONTRIBUTING',
'./LICENSE',
],
sitemap: {
hostname: 'https://docs.agoric.com',
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
"docs:dev": "NODE_OPTIONS=--openssl-legacy-provider vitepress dev main",
"docs:build": "NODE_OPTIONS=--openssl-legacy-provider vitepress build main",
"docs:preview": "NODE_OPTIONS=--openssl-legacy-provider vitepress preview main",
"docs:build-cf": "NODE_OPTIONS=--openssl-legacy-provider vitepress build main && cp _redirects dist/",
"docs:build-endo": "cd endo; yarn install; yarn docs:markdown-for-agoric-documentation-repo; mv api-docs ../main/reference/endo",
dckc marked this conversation as resolved.
Show resolved Hide resolved
"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",
dckc marked this conversation as resolved.
Show resolved Hide resolved
"//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'",
"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/",
"git-submodule:init": "git submodule init",
"git-submodule:update": "git submodule update --remote --merge",
"test": "ava",
"lint-fix": "yarn lint --fix",
"lint": "eslint 'snippets/**/*.js'",
Expand Down Expand Up @@ -65,7 +70,7 @@
"prettier": "^1.19.1",
"ses": "^0.18.8",
"stylus": "^0.62.0",
"vitepress": "^1.0.0-rc.42"
"vitepress": "^1.0.1"
},
"resolutions": {},
"globals": {
Expand Down
Loading
Loading