2.3 KiB
2.3 KiB
Docusaurus sites can be deployed to Netlify from the CI of our Forgejo instance. It's necessary to set the two variables:
NETLIFY_AUTH_TOKEN
(secret)NETLIFY_SITE_ID
(pretty sure isn't secret)
Running netlify build
without being logged in seems to generate errors. Rather just use npm run build
to generate the build in the build/
directory.
Running netlify deploy
will automatically detect these as environment variables, but setting the values as variables in Forgejo does not automatically make them into environment variables, so they should be passed explicitly in the commands.
Example Workflow
This workflow uses npm to manage the dependencies, rather than having them managed by Nix. This may introduce discrepancies between environments, but the package-lock.json
should be minimising those even if not providing any guarantees.
{
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 = [
git
netlify-cli
nodejs_22
];
};
}
);
}
name: Build and deploy
on:
push:
branches:
- main
jobs:
lint:
runs-on: docker
container:
image: ghcr.io/catthehacker/ubuntu:runner-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Nix
uses: https://guardianproject.dev/actions/install-nix-action@v31
- name: Install npm dependencies
run: nix develop --command npm install
- name: Generate OpenAPI section
run: nix develop --command npm run docusaurus gen-api-docs api
- name: Run build
run: nix develop --command npm run build
- name: Deploy
run: nix develop --command netlify deploy --auth ${{ secrets.NETLIFY_AUTH_TOKEN }} -s ${{ vars.NETLIFY_SITE_ID }}