Skip to content

Commit

Permalink
ci-scripts/build-docs-multiversion: init with GitHub CI
Browse files Browse the repository at this point in the history
  • Loading branch information
minijackson committed Dec 12, 2024
1 parent b9fae7b commit 124d18d
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/book-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ on:
# Allows running this workflow manually
workflow_dispatch:
push:
branches: [master]
branches:
- master
- nixos-24.05

permissions:
contents: read
Expand All @@ -17,22 +19,38 @@ concurrency:
jobs:
deploy:
if: "github.repository_owner == 'epics-extensions'"

permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest

steps:

# Checkout all documentation versions
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: main
path: dev
persist-credentials: false
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: nixos-24.05
path: nixos-24.05
persist-credentials: false

- uses: cachix/install-nix-action@3715ab1a11cac9e991980d7b4a28d80c7ebdd8f9 # v27
- name: "Build documentation book"
- uses: DeterminateSystems/magic-nix-cache-action@87b14cf437d03d37989d87f0fa5ce4f5dc1a330b # v8

- name: "Build documentation books"
run: |
nix build '.#docs' --print-build-logs
cp -Lr --no-preserve=mode,ownership ./result/share/doc/epnix/html ./book
nix run --print-build-logs './dev#ci-scripts/build-docs-multiversion'
- name: Setup Pages
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
- name: Upload artifact
Expand Down
47 changes: 47 additions & 0 deletions pkgs/ci-scripts/build-docs-multiversion.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
writeShellApplication,
writeText,
writers,
epnixLib,
}: let
stable = "nixos-24.05";
versions = [
"dev"
"nixos-24.05"
];
baseurl = "https://epics-extensions.github.io/EPNix";
# Make a redirection using the <meta> tag,
# with a delay of 1 second, because Google considers them not permanent
#
# We need non-permanent redirections, because the redirection will change
# when a new stable version is released
redirect = writeText "stable-redirect.html" ''
<meta http-equiv=refresh content="1;url=${stable}/">
'';

versionInfo = ver: {
name = ver;
url = "${baseurl}/${ver}/";
};
versions_json = writers.writeJSON "versions.json" (map versionInfo versions);
in
writeShellApplication {
name = "build-docs-multiversion";

text = ''
for version in ${toString versions}; do
mkdir -p "./book/$version"
cp ${versions_json} "./$version/docs/versions.json"
git -C "$version" add docs/versions.json
nix build "./$version#docs" --print-build-logs
cp -LrT --no-preserve=mode,ownership ./result/share/doc/epnix/html "./book/$version"
done
cp ${redirect} ./book/index.html
'';

meta = {
description = "Build ";
maintainers = with epnixLib.maintainers; [minijackson];
hidden = true;
};
}
4 changes: 4 additions & 0 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,9 @@ in

# Documentation support packages
psu-simulator = callPackage ./doc-support/psu-simulator {};

ci-scripts = recurseExtensible (_self: {
build-docs-multiversion = callPackage ./ci-scripts/build-docs-multiversion.nix {};
});
});
}

0 comments on commit 124d18d

Please sign in to comment.