Skip to content

Commit

Permalink
ci: add deploy actions for website
Browse files Browse the repository at this point in the history
Created a Firebase website for hosting the static site, as emitted by
`mdbook build`. Wired up GHA workflows to

  1. deploy ephemeral URLs on PRs
  2. deploy to prod on merge into main

The prod URL is currently `https://uips.penumbra.zone`.
Cobbled together a devshell via nix flake, same tooling as in other
repos, e.g. the guide [0].

[0] https://github.com/penumbra-zone/guide
  • Loading branch information
conorsch committed Nov 12, 2024
1 parent c060054 commit 493db33
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 1 deletion.
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-uips"
}
}
28 changes: 28 additions & 0 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

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_UIPS }}
channelId: live
projectId: penumbra-uips
29 changes: 29 additions & 0 deletions .github/workflows/firebase-hosting-pull-request.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

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_UIPS }}
projectId: penumbra-uips
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ index.html
cips/*.html

# WGs - same note as above
cips/wgs/**/*.html
cips/wgs/**/*.html

# ignore direnv; run `cp .envrc.example .envrc` to bootstrap dev tooling
.envrc
.direnv/

# firebase for static website hosting
.firebase/
10 changes: 10 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"hosting": {
"public": "book",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
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.

28 changes: 28 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# in flake.nix
{
inputs = {
# nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
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
markdownlint-cli
mdbook
];
};
}
);
}
20 changes: 20 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# display this help menu
list:
@just --list

# build static site
build:
mdbook build

# run code linters to check formatting
lint:
markdownlint --config .markdownlint.yaml '**/*.md'

# run dev env with livereload, for local editing
dev:
mdbook serve -n 127.0.0.1

# run dev env via firebase, for a more prod-like local editing experience
firebase-dev:
@just build
firebase emulators:start

0 comments on commit 493db33

Please sign in to comment.