226: docs: build and deploy with Nix r=zimbatm a=zimbatm



Co-authored-by: zimbatm <zimbatm@zimbatm.com>
This commit is contained in:
bors[bot] 2023-03-13 13:46:10 +00:00 committed by GitHub
commit 8709f4e322
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 67 additions and 29 deletions

View File

@ -1,22 +0,0 @@
# Build and deploy MkDocs to gh-pages for main branch
name: docs
on:
push:
branches:
- main
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
run: pip install mkdocs-material
- name: build and deploy to GitHub Pages
run: mkdocs gh-deploy --force --clean --verbose

37
.github/workflows/gh-pages.yml vendored Normal file
View File

@ -0,0 +1,37 @@
# Build and deploy MkDocs to gh-pages for main branch
name: gh-pages
on:
push:
branches:
- main
- staging
- trying
pull_request:
workflow_dispatch:
permissions:
contents: write
jobs:
gh-pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- uses: cachix/cachix-action@v12
with:
name: numtide
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build the docs
id: build
run: |
nix build .#docs
echo "result=$(readlink ./result)" >> $GITHUB_OUTPUT
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: "${{ steps.build.outputs.result }}/"

View File

@ -7,6 +7,7 @@ on:
- trying
pull_request:
workflow_dispatch:
jobs:
build:
strategy:

View File

@ -1,4 +1,4 @@
on: # rebuild any PRs and main branch changes
on: # rebuild any PRs and default branch changes
pull_request:
push:
branches:

View File

@ -9,5 +9,6 @@ status = [
"clippy",
"clippy_check",
"devShell default [x86_64-linux]",
"gh-pages",
"package default [x86_64-linux]"
]

View File

@ -86,7 +86,9 @@ let
shfmt
terraform
mdbook
# Docs
mkdocs
python310Packages.mkdocs-material
]);
});
in

View File

@ -1,11 +1,30 @@
{ mdbook, stdenv }:
{ stdenv, mkdocs, python310Packages }:
stdenv.mkDerivation {
name = "treefmt-docs";
buildInputs = [ mdbook ];
src = ./.;
buildPhase = "mdbook build";
src = builtins.path {
name = "treefmt-docs";
path = ./.;
};
# Re-create the folder structure since mkdocs insists on having the
# mkdocs.yml at the root of the repo.
unpackPhase = ''
cp -r --no-preserve=mode $src docs
cp ${../mkdocs.yml} mkdocs.yml
'';
nativeBuildInputs = [
mkdocs
python310Packages.mkdocs-material
];
buildPhase = ''
mkdocs build
'';
installPhase = ''
mv book $out
mv site $out
'';
}