Skip to content

Commit

Permalink
feat: onboarding docs with spawn (#22)
Browse files Browse the repository at this point in the history
* onboarding wip

* rm onboarding raw docs

* fix gitignore

* rm netlify for now

* add spawn to onboarding docs

* remoev default docs/ dir

* fix: onboarding to local reference

* sync_onboarding.sh
  • Loading branch information
Reecepbcups authored Nov 7, 2024
1 parent 8ed06e8 commit 3c28ad0
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 98 deletions.
136 changes: 68 additions & 68 deletions .github/workflows/deploy-netlify.yaml
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
name: 'Netlify Deploy'
# name: 'Netlify Deploy'

# Disable `Pretty URLs` (Site Confiuration > Build & Deploy > Post Processing > Pretty URLs)
# # Disable `Pretty URLs` (Site Confiuration > Build & Deploy > Post Processing > Pretty URLs)

permissions:
pull-requests: write
# permissions:
# pull-requests: write

on:
# TODO: cron
# release:
# types: [published]
push:
# branches:
# - main
# on:
# # TODO: cron
# # release:
# # types: [published]
# push:
# # branches:
# # - main

env:
BRANCH_NAME: ${{ github.ref_name }}
# env:
# BRANCH_NAME: ${{ github.ref_name }}

jobs:
deploy:
name: 'Deploy to Netlify'
runs-on: ubuntu-latest
steps:
# ensure the secrets are set, if not, error
- name: Check Secrets
run: |
if [ -z "${{ secrets.NETLIFY_SITE_ID }}" ]; then
echo "NETLIFY_SITE_ID is not set. Please set it in the repository secrets."
exit 1
fi
if [ -z "${{ secrets.NETLIFY_AUTH_TOKEN }}" ]; then
echo "NETLIFY_AUTH_TOKEN is not set. Please set it in the repository secrets."
exit 1
fi
# jobs:
# deploy:
# name: 'Deploy to Netlify'
# runs-on: ubuntu-latest
# steps:
# # ensure the secrets are set, if not, error
# - name: Check Secrets
# run: |
# if [ -z "${{ secrets.NETLIFY_SITE_ID }}" ]; then
# echo "NETLIFY_SITE_ID is not set. Please set it in the repository secrets."
# exit 1
# fi
# if [ -z "${{ secrets.NETLIFY_AUTH_TOKEN }}" ]; then
# echo "NETLIFY_AUTH_TOKEN is not set. Please set it in the repository secrets."
# exit 1
# fi

- name: Repository Checkout
uses: actions/checkout@v4
# - name: Repository Checkout
# uses: actions/checkout@v4

- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
# - name: Setup NodeJS
# uses: actions/setup-node@v4
# with:
# node-version: 20
# cache: "npm"

- name: Install Netlify
run: npm install [email protected] -g
# - name: Install Netlify
# run: npm install [email protected] -g

- name: Install Dependencies
run: npm ci
# - name: Install Dependencies
# run: npm ci

- name: 🤔 Sync latest Upstream
run: make sync-docs
# - name: 🤔 Sync latest Upstream
# run: make sync-docs

- name: Build website 🔨
run: make build-docs
# - name: Build website 🔨
# run: make build-docs

# if the branch is not main, then its a deploy to non prod, set DEPLOY_TO_PROD to false
- name: Set Deploy to Prod
run: |
if [ "${{ env.BRANCH_NAME }}" != "main" ]; then
echo "Deploying to non-prod environment"
echo "Setting DEPLOY_TO_PROD to false"
echo "DEPLOY_TO_PROD=false" >> $GITHUB_ENV
else
echo "Deploying to prod environment"
echo "Setting DEPLOY_TO_PROD to true"
echo "DEPLOY_TO_PROD=true" >> $GITHUB_ENV
fi
# # if the branch is not main, then its a deploy to non prod, set DEPLOY_TO_PROD to false
# - name: Set Deploy to Prod
# run: |
# if [ "${{ env.BRANCH_NAME }}" != "main" ]; then
# echo "Deploying to non-prod environment"
# echo "Setting DEPLOY_TO_PROD to false"
# echo "DEPLOY_TO_PROD=false" >> $GITHUB_ENV
# else
# echo "Deploying to prod environment"
# echo "Setting DEPLOY_TO_PROD to true"
# echo "DEPLOY_TO_PROD=true" >> $GITHUB_ENV
# fi

# https://app.netlify.com/user/applications#personal-access-tokens
# ref: https://www.raulmelo.me/en/blog/deploying-netlify-github-actions-guide
# ref: NETLIFY_SITE_ID is a UUID from Netlify
- name: Deploy to Netlify
uses: jsmrcaga/[email protected]
with:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_DEPLOY_MESSAGE: "Deployed from GitHub action"
NETLIFY_DEPLOY_TO_PROD: ${{ env.DEPLOY_TO_PROD }}
install_command: "echo Skipping installing the dependencies"
build_command: "echo Skipping building the web files"
# # https://app.netlify.com/user/applications#personal-access-tokens
# # ref: https://www.raulmelo.me/en/blog/deploying-netlify-github-actions-guide
# # ref: NETLIFY_SITE_ID is a UUID from Netlify
# - name: Deploy to Netlify
# uses: jsmrcaga/[email protected]
# with:
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# NETLIFY_DEPLOY_MESSAGE: "Deployed from GitHub action"
# NETLIFY_DEPLOY_TO_PROD: ${{ env.DEPLOY_TO_PROD }}
# install_command: "echo Skipping installing the dependencies"
# build_command: "echo Skipping building the web files"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ dsource*
ibc-go*
cometbft*
cosmos-sdk*
onboarding*
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dev-docs:
sync-docs:
@bash sync_cosmos-sdk.sh
@bash sync_ibc.sh
@bash sync_onboarding.sh

.PHONY: help
help: Makefile
Expand Down
8 changes: 0 additions & 8 deletions docs/intro.md

This file was deleted.

38 changes: 18 additions & 20 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion

const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require("prism-react-renderer/themes/dracula");
Expand All @@ -19,35 +18,35 @@ function mapValidPluginsToDropDownVersions(docs) {
});
}

const OrgName = "interchainio";
const ProjectName = "dev-portal-docsite";

// The default slug URL for the docs site. Github Pages requires a base URL to be set
// to the name of the repository. The action sets IS_GH_PAGES to true if deploying to Github Pages.
var baseURL = "/"
if (process.env.IS_GH_PAGES) {
baseURL = "/dev-portal-docsite/"
baseURL = `/${ProjectName}/`
}

/** @type {import('@docusaurus/types').Config} */
const config = {
title: "Interchain Stack",
tagline: "Your gateway into your Interchain future",
url: "https://docs-interchain.io", // TODO:
url: "https://docs-interchain.io", // TODO: docs.interchain.io
baseUrl: baseURL,
onBrokenLinks: "warn", // TODO: throw for prod
onBrokenMarkdownLinks: "warn",
favicon: "img/favicon.ico",
organizationName: "interchainio", // Usually your GitHub org/user name.
projectName: "dev-portal-docsite", // Usually your repo name.
organizationName: OrgName,
projectName: ProjectName,

presets: [
[
"classic",
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
// id: 'docs', // omitted => default instance
routeBasePath: "docs", // TODO: change this to be onboarding?
sidebarPath: require.resolve("./sidebars.js"),
// Please change this to your repo.
editUrl: "https://github.com/interchainio/dev-portal-docsite/",
},
// removes required default docs/ folder for the project. This project uses nested so it is not required.
docs: false,
theme: {
customCss: require.resolve("./src/css/custom.css"),
},
Expand Down Expand Up @@ -112,13 +111,12 @@ const config = {
href: "/",
},
items: [
// Onboarding documentation? (i.e. Spawn, or just quick start guides)
// {
// type: "doc",
// position: "left",
// docId: "intro",
// label: "Onboard",
// },
// new items require updating:
{
position: "left",
to: "/onboarding",
label: "Onboarding",
},
{
to: "/ibc-go", // To highlight the navbar item, you must link to a document, not a top-level directory
position: "left",
Expand Down Expand Up @@ -150,7 +148,7 @@ const config = {
// Version drop downs are merged via the theme/NavBarItem/DocsVersionDropdownNavbarItem.js
...mapValidPluginsToDropDownVersions(validDocs),
{
href: "https://github.com/interchainio/dev-portal-docsite/",
href: `https://github.com/${OrgName}/${ProjectName}`,
html: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="github-icon">
<path fill-rule="evenodd" clip-rule="evenodd" d="M12 0.300049C5.4 0.300049 0 5.70005 0 12.3001C0 17.6001 3.4 22.1001 8.2 23.7001C8.8 23.8001 9 23.4001 9 23.1001C9 22.8001 9 22.1001 9 21.1001C5.7 21.8001 5 19.5001 5 19.5001C4.5 18.1001 3.7 17.7001 3.7 17.7001C2.5 17.0001 3.7 17.0001 3.7 17.0001C4.9 17.1001 5.5 18.2001 5.5 18.2001C6.6 20.0001 8.3 19.5001 9 19.2001C9.1 18.4001 9.4 17.9001 9.8 17.6001C7.1 17.3001 4.3 16.3001 4.3 11.7001C4.3 10.4001 4.8 9.30005 5.5 8.50005C5.5 8.10005 5 6.90005 5.7 5.30005C5.7 5.30005 6.7 5.00005 9 6.50005C10 6.20005 11 6.10005 12 6.10005C13 6.10005 14 6.20005 15 6.50005C17.3 4.90005 18.3 5.30005 18.3 5.30005C19 7.00005 18.5 8.20005 18.4 8.50005C19.2 9.30005 19.6 10.4001 19.6 11.7001C19.6 16.3001 16.8 17.3001 14.1 17.6001C14.5 18.0001 14.9 18.7001 14.9 19.8001C14.9 21.4001 14.9 22.7001 14.9 23.1001C14.9 23.4001 15.1 23.8001 15.7 23.7001C20.5 22.1001 23.9 17.6001 23.9 12.3001C24 5.70005 18.6 0.300049 12 0.300049Z" fill="currentColor"/>
</svg>
Expand Down
3 changes: 1 addition & 2 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ function HeroSection() {
</p>
{/* Buttons */}
<div className="mt-7 grid gap-3 w-full sm:inline-flex">
{/* TODO: move into the docs-interchain repo here */}
<Link to="https://rollchains.github.io/spawn/v0.50/">
<Link to={useBaseUrl("/onboarding")}>
<Button size="lg">Quick Start</Button>
{/* <Button variant={"outline"} size={"lg"}>
Contact sales team
Expand Down
3 changes: 3 additions & 0 deletions src/theme/NavbarItem/DocsVersionDropdownNavbarItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export default function DocsVersionDropdownNavbarItemWrapper(props) {
return null
}

// print out props
console.log(docsPluginId, props)

return (
<>
<DocsVersionDropdownNavbarItem {...props} />
Expand Down
68 changes: 68 additions & 0 deletions sync_onboarding.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
#
# To run this script, ensure you have setup the docusaurus.config.js first for new repos.
# This then migrates it over to here.
#

CURRENT_DIR=$(pwd)
source ./sync_helpers.sh
DOCS_NAME=onboarding

DOCS_DIR_TARGET=dsource-onboarding
DOCS_DIR=$CURRENT_DIR/$DOCS_DIR_TARGET/docs

main() {
download_docs_source

copy_over_core

fix_references
# fix_components
}

# == HELPER FUNCTIONS ==
unsafe_cleanup_ibc_go() {
# useful for testing this script locally and resetting state
rm -rf ./$DOCS_NAME ./${DOCS_NAME}_versioned_sidebars ./${DOCS_NAME}_versioned_docs ./static/img/$DOCS_NAME/ ./src/components/$DOCS_NAME/
rm -rf ./$DOCS_DIR ./${DOCS_NAME}_versions.json
}


download_docs_source() {
# Downloads documentation source for the repo
git -C "$DOCS_DIR_TARGET" pull || git clone --depth 1 https://github.com/rollchains/spawn.git $DOCS_DIR_TARGET

if [ -z "$DOCS_NAME" ]; then
echo "DOCS_NAME is unset. Set it to the name of the docs you are syncing (i.e. ibc-go)."
panic
fi

mkdir -p ./$DOCS_NAME ./${DOCS_NAME}_versioned_sidebars ./${DOCS_NAME}_versioned_docs ./static/img/$DOCS_NAME/
}

copy_over_core() {
# docs
cp -r $DOCS_DIR/docs ./${DOCS_NAME}

# versioned docs
cp $DOCS_DIR/versions.json ./${DOCS_NAME}_versions.json
cp -r $DOCS_DIR/versioned_sidebars/* ./${DOCS_NAME}_versioned_sidebars
cp -r $DOCS_DIR/versioned_docs/* ./${DOCS_NAME}_versioned_docs

# core
cp $DOCS_DIR/sidebars.js ./${DOCS_NAME}/sidebars.js

# images
cp -r $DOCS_DIR/static/img/* ./static/img/${DOCS_NAME}/
}

fix_references() {
# update component import references
# replace "./src/components/${DOCS_NAME}" "static/img/" "static/img/${DOCS_NAME}/"

replace "./${DOCS_NAME}_versioned_docs" '<!-- markdown-link-check-disable -->' ''
replace "./${DOCS_NAME}_versioned_docs" '<!-- markdown-link-check-enable -->' ''
}

# == MAIN ==
main

0 comments on commit 3c28ad0

Please sign in to comment.