2024-03-18 06:30:40 +01:00
|
|
|
name: Documentation and GitHub Pages
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2024-05-05 08:18:15 +02:00
|
|
|
tags:
|
|
|
|
- '*'
|
2024-03-18 06:30:40 +01:00
|
|
|
|
|
|
|
# Allows you to run this workflow manually from the Actions tab
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
env:
|
|
|
|
# Required to make some things output color
|
|
|
|
TERM: ansi
|
|
|
|
# Publishing to my nix binary cache
|
|
|
|
ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }}
|
2024-06-15 23:32:51 +02:00
|
|
|
# conduwuit.cachix.org
|
|
|
|
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
|
2024-03-18 06:30:40 +01:00
|
|
|
# Custom nix binary cache if fork is being used
|
|
|
|
ATTIC_ENDPOINT: ${{ vars.ATTIC_ENDPOINT }}
|
|
|
|
ATTIC_PUBLIC_KEY: ${{ vars.ATTIC_PUBLIC_KEY }}
|
2024-07-14 06:47:56 +02:00
|
|
|
# Get error output from nix that we can actually use, and use our binary caches for the earlier CI steps
|
|
|
|
NIX_CONFIG: |
|
|
|
|
show-trace = true
|
|
|
|
extra-substituters = https://attic.kennel.juneis.dog/conduit https://attic.kennel.juneis.dog/conduwuit https://cache.lix.systems https://conduwuit.cachix.org
|
|
|
|
extra-trusted-public-keys = conduit:eEKoUwlQGDdYmAI/Q/0slVlegqh/QmAvQd7HBSm21Wk= conduwuit:BbycGUgTISsltcmH0qNjFR9dbrQNYgdIAcmViSGoVTE= cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o= conduwuit.cachix.org-1:MFRm6jcnfTf0jSAbmvLfhO3KBMt4px+1xaereWXp8Xg=
|
2024-03-18 06:30:40 +01:00
|
|
|
|
|
|
|
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
|
|
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
|
|
concurrency:
|
|
|
|
group: "pages"
|
|
|
|
cancel-in-progress: false
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
docs:
|
|
|
|
name: Documentation and GitHub Pages
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
pages: write
|
|
|
|
id-token: write
|
|
|
|
|
|
|
|
environment:
|
|
|
|
name: github-pages
|
|
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
|
|
|
|
|
|
steps:
|
2024-07-26 01:39:47 +02:00
|
|
|
- name: Free Disk Space (Ubuntu)
|
|
|
|
uses: jlumbroso/free-disk-space@main
|
|
|
|
|
2024-03-18 06:30:40 +01:00
|
|
|
- name: Sync repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Setup GitHub Pages
|
|
|
|
if: github.event_name != 'pull_request'
|
2024-03-30 03:44:16 +01:00
|
|
|
uses: actions/configure-pages@v5
|
2024-03-18 06:30:40 +01:00
|
|
|
|
2024-07-03 04:51:59 +02:00
|
|
|
- uses: nixbuild/nix-quick-install-action@v28
|
2024-06-15 23:31:09 +02:00
|
|
|
|
2024-07-03 04:51:59 +02:00
|
|
|
- name: Restore and cache Nix store
|
2024-07-03 06:13:39 +02:00
|
|
|
uses: nix-community/cache-nix-action@v5.1.0
|
2024-06-15 23:11:25 +02:00
|
|
|
with:
|
2024-07-03 04:51:59 +02:00
|
|
|
# restore and save a cache using this key
|
|
|
|
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/.lock') }}
|
|
|
|
# if there's no cache hit, restore a cache by this prefix
|
|
|
|
restore-prefixes-first-match: nix-${{ runner.os }}-
|
|
|
|
# collect garbage until Nix store size (in bytes) is at most this number
|
|
|
|
# before trying to save a new cache
|
|
|
|
gc-max-store-size-linux: 2073741824
|
|
|
|
# do purge caches
|
|
|
|
purge: true
|
|
|
|
# purge all versions of the cache
|
|
|
|
purge-prefixes: nix-${{ runner.os }}-
|
|
|
|
# created more than this number of seconds ago relative to the start of the `Post Restore` phase
|
|
|
|
purge-last-accessed: 86400
|
|
|
|
# except the version with the `primary-key`, if it exists
|
|
|
|
purge-primary-key: never
|
|
|
|
# always save the cache
|
|
|
|
save-always: true
|
2024-03-18 06:30:40 +01:00
|
|
|
|
2024-09-13 05:09:10 +02:00
|
|
|
- name: Enable Cachix binary cache
|
|
|
|
run: |
|
|
|
|
nix profile install nixpkgs#cachix
|
|
|
|
cachix use crane
|
|
|
|
cachix use nix-community
|
|
|
|
|
2024-06-15 23:31:09 +02:00
|
|
|
- name: Apply Nix binary cache configuration
|
2024-03-18 06:30:40 +01:00
|
|
|
run: |
|
2024-07-03 04:51:59 +02:00
|
|
|
sudo tee -a "${XDG_CONFIG_HOME:-$HOME/.config}/nix/nix.conf" > /dev/null <<EOF
|
2024-06-17 01:17:29 +02:00
|
|
|
extra-substituters = https://attic.kennel.juneis.dog/conduit https://attic.kennel.juneis.dog/conduwuit https://cache.lix.systems https://conduwuit.cachix.org
|
2024-07-03 04:51:59 +02:00
|
|
|
extra-trusted-public-keys = conduit:eEKoUwlQGDdYmAI/Q/0slVlegqh/QmAvQd7HBSm21Wk= conduwuit:BbycGUgTISsltcmH0qNjFR9dbrQNYgdIAcmViSGoVTE= cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o= conduwuit.cachix.org-1:MFRm6jcnfTf0jSAbmvLfhO3KBMt4px+1xaereWXp8Xg=
|
2024-06-15 23:31:09 +02:00
|
|
|
EOF
|
2024-03-18 06:30:40 +01:00
|
|
|
|
2024-06-15 23:31:09 +02:00
|
|
|
- name: Use alternative Nix binary caches if specified
|
|
|
|
if: ${{ (env.ATTIC_ENDPOINT != '') && (env.ATTIC_PUBLIC_KEY != '') }}
|
|
|
|
run: |
|
2024-07-03 04:51:59 +02:00
|
|
|
sudo tee -a "${XDG_CONFIG_HOME:-$HOME/.config}/nix/nix.conf" > /dev/null <<EOF
|
2024-06-15 23:31:09 +02:00
|
|
|
extra-substituters = ${{ env.ATTIC_ENDPOINT }}
|
|
|
|
extra-trusted-public-keys = ${{ env.ATTIC_PUBLIC_KEY }}
|
|
|
|
EOF
|
2024-03-18 06:30:40 +01:00
|
|
|
|
2024-06-15 23:31:09 +02:00
|
|
|
- name: Prepare build environment
|
|
|
|
run: |
|
|
|
|
echo 'source $HOME/.nix-profile/share/nix-direnv/direnvrc' > "$HOME/.direnvrc"
|
2024-07-14 07:33:38 +02:00
|
|
|
nix profile install --inputs-from . nixpkgs#direnv nixpkgs#nix-direnv
|
2024-06-15 23:31:09 +02:00
|
|
|
direnv allow
|
|
|
|
nix develop --command true
|
2024-03-18 06:30:40 +01:00
|
|
|
|
2024-05-02 05:30:49 +02:00
|
|
|
- name: Cache CI dependencies
|
2024-03-18 06:30:40 +01:00
|
|
|
run: |
|
2024-09-08 20:51:34 +02:00
|
|
|
bin/nix-build-and-cache ci
|
2024-03-18 06:30:40 +01:00
|
|
|
|
2024-07-03 09:32:18 +02:00
|
|
|
- name: Run lychee and markdownlint
|
|
|
|
run: |
|
|
|
|
direnv exec . engage just lints lychee
|
|
|
|
direnv exec . engage just lints markdownlint
|
|
|
|
|
2024-03-18 06:30:40 +01:00
|
|
|
- name: Build documentation (book)
|
|
|
|
run: |
|
2024-09-08 20:51:34 +02:00
|
|
|
bin/nix-build-and-cache just .#book
|
2024-07-25 04:45:27 +02:00
|
|
|
|
|
|
|
cp -r --dereference result public
|
|
|
|
|
2024-03-18 06:30:40 +01:00
|
|
|
- name: Upload generated documentation (book) as normal artifact
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: public
|
|
|
|
path: public
|
|
|
|
if-no-files-found: error
|
|
|
|
# don't compress again
|
|
|
|
compression-level: 0
|
|
|
|
|
|
|
|
- name: Upload generated documentation (book) as GitHub Pages artifact
|
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
uses: actions/upload-pages-artifact@v3
|
|
|
|
with:
|
|
|
|
path: public
|
|
|
|
|
|
|
|
- name: Deploy to GitHub Pages
|
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
id: deployment
|
|
|
|
uses: actions/deploy-pages@v4
|