Skip to content

Commit

Permalink
ci: add deploy workflows
Browse files Browse the repository at this point in the history
Also includes a nix-based dev env for build tooling, which will install
requirements like `pnpm` and `firebase-tools`.

Opts in to creating a fully static export of the site. Requires that we
disable image optimization, which only works with a server on the
backend.

Uses the firebase-generated github action workflows to deploy to
static-site hosting.
  • Loading branch information
conorsch committed Jul 23, 2024
1 parent b4de8ea commit 3cd8c0c
Show file tree
Hide file tree
Showing 12 changed files with 245 additions and 23 deletions.
1 change: 1 addition & 0 deletions .envrc.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "penumbra-guide"
}
}
29 changes: 29 additions & 0 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
#
# It will build the static site and deploy it to the live prod URL.

name: Deploy to Firebase Hosting on merge
on:
push:
branches:
- main
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install nix
uses: DeterminateSystems/nix-installer-action@main
- name: load nix cache
uses: DeterminateSystems/magic-nix-cache-action@main

- name: build static docroot
run: nix develop --command just build

- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_PENUMBRA_GUIDE }}
channelId: live
projectId: penumbra-guide
31 changes: 31 additions & 0 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
#
# It will build the static site, deploy it to an ephemeral URL, and post a comment
# to the PR with that URL for review.

name: Deploy to Firebase Hosting on PR
on: pull_request
permissions:
checks: write
contents: read
pull-requests: write
jobs:
build_and_preview:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install nix
uses: DeterminateSystems/nix-installer-action@main
- name: load nix cache
uses: DeterminateSystems/magic-nix-cache-action@main

- name: build static docroot
run: nix develop --command just build

- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_PENUMBRA_GUIDE }}
projectId: penumbra-guide
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ yarn-error.log*

# Local env files
.env*.local
.envrc
.direnv/

# Vercel
.vercel
Expand Down Expand Up @@ -63,3 +65,6 @@ Thumbs.db

# Nextra specific
.nextra

# Firebase static site hosting
.firebase/
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Penumbra Guide

This repo holds the end-user documentation for Penumbra, hosted at [https://guide.penumbra.zone](https://guide.penumbra.zone).

## Contributing

1. Install [nix](https://nixos.org/download/).
2. Run `nix develop --enable-experimental-features "nix-command flake"`
3. Run `just dev` for a livereload environment.

## Directory layout

The documentation source resides in `pages/`. Docs files are written in [Markdown](https://www.markdownguide.org/),
and served via [Nextra](https://nextra.site/).
32 changes: 32 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"hosting": {
"public": "out",
"redirects": [
{
"source": "/main/index.html",
"destination": "/",
"type": 302
},
{
"regex": "/main/pd(?P<page>.*)",
"destination": "/node/pd:page",
"type": 302
},
{
"regex": "/main/pclientd(?P<page>.*)",
"destination": "/node/pclientd:page",
"type": 302
},
{
"regex": "/main/(?P<page>.*)",
"destination": "/:page",
"type": 302
},
{
"source": "/node/pd/join-testnet.html",
"destination": "/node/pd/join-network.html",
"type": 302
}
]
}
}
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# in flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system ;
};
in
with pkgs;
{
devShells.default = mkShell {
buildInputs = [
firebase-tools
just
pnpm
];
};
}
);
}
11 changes: 11 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# display this help menu
list:
@just --list

# build static site
build:
pnpm install && pnpm build

# run dev env with livereload, for local editing
dev:
pnpm dev
9 changes: 8 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ const withNextra = require('nextra')({
themeConfig: './theme.config.jsx'
})

module.exports = withNextra()
module.exports = withNextra({
// Attempt to generate static site, via https://nextjs.org/docs/pages/building-your-application/deploying/static-exports
output: 'export',
// Disable image optimization, as it doesn't work for SSG.
images: {
unoptimized: true,
},
})

// If you have other Next.js configurations, you can pass them as the parameter:
// module.exports = withNextra({ /* other next.js config */ })
44 changes: 22 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3cd8c0c

Please sign in to comment.