Skip to content

Commit

Permalink
feat: deploy integration (gh pages) (#21)
Browse files Browse the repository at this point in the history
* feat: gh pages deploy on merge to main or workflow dispatch

* fix: url for github pages?

* netlify-deploy

* fix: secrets

* url hostname

* fix: deploy with action instead

* feat: status check with action push to non prod deploy

* attempt header overwrite for CORS

* TODO: UNDO ME simplify build times

* f

* simplify sync docs for now

* f

* idk man

* direct widget

* rm non working hacky patches for AI cors

* fix: github loc and todo

* url

* deploy to gh pages
  • Loading branch information
Reecepbcups authored Nov 5, 2024
1 parent 63c3483 commit 5466866
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 2 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/deploy-github-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy to GitHub Pages

permissions:
contents: write
actions: write
pages: write

on:
workflow_dispatch:
push:
branches:
- main

jobs:
deploy:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
cache-dependency-path: package-lock.json

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

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

- name: Deploy 🚀
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: build
single-commit: true
81 changes: 81 additions & 0 deletions .github/workflows/deploy-netlify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: 'Netlify Deploy'

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

permissions:
pull-requests: write

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

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
- name: Repository Checkout
uses: actions/checkout@v4

- 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 Dependencies
run: npm ci

- name: 🤔 Sync latest Upstream
run: make sync-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
# 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"
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

## build-docs: Build the documentation to static files.
.PHONY: build-docs
build-docs:
@npm ci && npm run build

## serve-docs: Run docs server
.PHONY: serve-docs
serve-docs:
@npm run serve

## dev-docs: Run dev docs instance
.PHONY: dev-docs
dev-docs:
@npm run start

## sync-docs: Grab the latest upstream documentation
.PHONY: sync-docs
sync-docs:
@bash sync_cosmos-sdk.sh
@bash sync_ibc.sh

.PHONY: help
help: Makefile
@echo
@echo " Choose a command run in 'dev-portal'"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo


2 changes: 2 additions & 0 deletions _headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/*
Access-Control-Allow-Origin: *
4 changes: 2 additions & 2 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function mapValidPluginsToDropDownVersions(docs) {
const config = {
title: "Interchain Stack",
tagline: "Your gateway into your Interchain future",
url: "https://docs.interchain.io",
url: "https://docs-interchain.io", // TODO:
baseUrl: "/",
onBrokenLinks: "warn", // TODO: throw for prod
onBrokenMarkdownLinks: "warn",
Expand Down Expand Up @@ -135,7 +135,7 @@ const config = {
// Version drop downs are merged via the theme/NavBarItem/DocsVersionDropdownNavbarItem.js
...mapValidPluginsToDropDownVersions(validDocs),
{
href: "https://github.com/interchainio",
href: "https://github.com/interchainio/dev-portal-docsite/",
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
5 changes: 5 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# a request to `https://kapa-widget-proxy-la7dkmplpq-uc.a.run.app/proxy/query/v2/chat/stream/` is made but results in a CORS error with netlify. Fix this using a redirect
[[headers]]
for = "/*" # you can configure the correct paths here
[headers.values]
access-control-allow-origin = "*" # see a list of allowed values here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin

0 comments on commit 5466866

Please sign in to comment.