|
1 |
| -name: Build and deploy documentation |
| 1 | +name: Documentation |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
5 |
| - # Runs on pushes targeting the release branches |
6 | 5 | branches:
|
7 | 6 | - main
|
8 |
| - |
9 |
| - # Allows you to run this workflow manually from the Actions tab |
| 7 | + # Allow running manually |
10 | 8 | workflow_dispatch:
|
11 | 9 |
|
12 |
| -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
13 |
| -permissions: |
14 |
| - contents: read |
15 |
| - pages: write |
16 |
| - id-token: write |
17 |
| - |
18 | 10 | # Allow one concurrent deployment
|
19 | 11 | concurrency:
|
20 |
| - group: "pages" |
| 12 | + group: docs-website |
21 | 13 | cancel-in-progress: true
|
22 | 14 |
|
23 | 15 | jobs:
|
24 |
| - deploy: |
25 |
| - if: github.repository == 'nix-community/nixvim' |
26 |
| - environment: |
27 |
| - name: github-pages |
28 |
| - url: ${{ steps.deployment.outputs.page_url }} |
| 16 | + build: |
| 17 | + name: Build ${{ matrix.name }} |
29 | 18 | runs-on: ubuntu-latest
|
30 |
| - timeout-minutes: 40 |
31 | 19 |
|
32 |
| - env: |
33 |
| - repo: ${{ github.repository }} |
34 |
| - repoName: ${{ github.event.repository.name }} |
35 |
| - out: docs-build |
| 20 | + strategy: |
| 21 | + fail-fast: true |
| 22 | + matrix: |
| 23 | + # TODO: generate matrix from version-info.toml |
| 24 | + include: |
| 25 | + - name: unstable |
| 26 | + ref: main |
| 27 | + sub-path: "" |
| 28 | + base-href: /nixvim/ |
| 29 | + - name: "25.05" |
| 30 | + ref: nixos-25.05 |
| 31 | + sub-path: "25.05" |
| 32 | + base-href: /nixvim/25.05/ |
| 33 | + - name: "24.11" |
| 34 | + ref: nixos-24.11 |
| 35 | + sub-path: "24.11" |
| 36 | + base-href: /nixvim/24.11/ |
36 | 37 |
|
37 | 38 | steps:
|
38 | 39 | - name: Install nix
|
39 | 40 | uses: cachix/install-nix-action@v31
|
40 |
| - with: |
41 |
| - nix_path: nixpkgs=channel:nixos-unstable |
42 | 41 |
|
43 | 42 | - name: Configure cachix
|
44 | 43 | uses: cachix/cachix-action@v16
|
45 | 44 | with:
|
46 | 45 | name: nix-community
|
47 |
| - authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" |
| 46 | + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} |
48 | 47 |
|
49 |
| - - name: Build docs |
50 |
| - run: | |
51 |
| - set -ex |
| 48 | + - name: Checkout |
| 49 | + uses: actions/checkout@v4 |
| 50 | + with: |
| 51 | + ref: ${{ inputs.ref }} |
52 | 52 |
|
53 |
| - # A list of all doc versions to be built, |
54 |
| - # (Written to versions.json) |
55 |
| - echo ' |
| 53 | + # Uses the build-docs action from the checked-out nixvim branch |
| 54 | + - name: Build docs |
| 55 | + uses: ./.github/actions/build-docs |
| 56 | + with: |
| 57 | + artifact-name: ${{ matrix.name }}-docs |
| 58 | + sub-path: ${{ matrix.sub-path }} |
| 59 | + base-href: ${{ matrix.base-href }} |
| 60 | + # TODO: generate JSON from version-info.toml |
| 61 | + versions: > |
56 | 62 | [
|
57 | 63 | {
|
58 | 64 | "branch": "main",
|
59 |
| - "nixpkgsBranch": "nixos-unstable" |
| 65 | + "nixpkgsBranch": "nixos-unstable", |
| 66 | + "baseHref": "/nixvim/" |
60 | 67 | },
|
61 | 68 | {
|
62 | 69 | "branch": "nixos-25.05",
|
63 | 70 | "nixpkgsBranch": "nixos-25.05",
|
64 |
| - "subPath": "25.05" |
| 71 | + "baseHref": "/nixvim/25.05/" |
65 | 72 | },
|
66 | 73 | {
|
67 | 74 | "branch": "nixos-24.11",
|
68 | 75 | "nixpkgsBranch": "nixos-24.11",
|
69 |
| - "subPath": "24.11" |
| 76 | + "baseHref": "/nixvim/24.11/" |
70 | 77 | }
|
71 | 78 | ]
|
72 |
| - ' | jq \ |
73 |
| - --arg repoName "$repoName" \ |
74 |
| - 'map( |
75 |
| - . |
76 |
| - # Ensure subPath is a string |
77 |
| - | .subPath = (.subPath // "") |
78 |
| - # Construct baseHref from $repoName and .subPath |
79 |
| - | .baseHref = ( |
80 |
| - .subPath |
81 |
| - | if . == "" then "" else "/\(.)" end |
82 |
| - | $repoName + . |
83 |
| - | "/\(.)/" |
84 |
| - ) |
85 |
| - )' > versions.json |
86 |
| -
|
87 |
| - # 1: branch |
88 |
| - # 2: baseHref |
89 |
| - # 3: install dir |
90 |
| - build() { |
91 |
| - flakeref="github:${repo}${1:+/$1}" |
92 |
| - baseHref="$2" |
93 |
| - installDir="${out}${3:+/$3}" |
94 |
| -
|
95 |
| - # Build docs for the given flake ref, overriding the relevant derivation args |
96 |
| - nix build --impure \ |
97 |
| - --argstr flakeref "$flakeref" \ |
98 |
| - --argstr baseHref "$baseHref" \ |
99 |
| - --arg-from-file versionsJson versions.json \ |
100 |
| - --expr ' |
101 |
| - { |
102 |
| - flakeref, |
103 |
| - baseHref, |
104 |
| - versionsJson, |
105 |
| - system ? builtins.currentSystem, |
106 |
| - }: |
107 |
| - let |
108 |
| - flake = builtins.getFlake flakeref; |
109 |
| - packages = flake.outputs.packages.${system}; |
110 |
| - in |
111 |
| - packages.docs.override { |
112 |
| - inherit baseHref; |
113 |
| - availableVersions = builtins.fromJSON versionsJson; |
114 |
| - } |
115 |
| - ' |
116 |
| -
|
117 |
| - # Copy the result to the install dir |
118 |
| - mkdir -p "$installDir" |
119 |
| - cp -r result/* "$installDir" |
120 |
| - } |
121 |
| -
|
122 |
| - # For each version of the docs... |
123 |
| - jq -c '.[]' versions.json | |
124 |
| - while IFS=$"\n" read -r entry; do |
125 |
| - branch=$(echo "$entry" | jq -r '.branch') |
126 |
| - baseHref=$(echo "$entry" | jq -r '.baseHref') |
127 |
| - installDir=$(echo "$entry" | jq -r '.subPath') |
128 |
| -
|
129 |
| - # Build this version of the docs |
130 |
| - build "$branch" "$baseHref" "$installDir" |
131 |
| - done |
| 79 | +
|
| 80 | + combine: |
| 81 | + name: Combine builds |
| 82 | + runs-on: ubuntu-latest |
| 83 | + needs: build |
| 84 | + |
| 85 | + env: |
| 86 | + in: artifacts |
| 87 | + out: combined |
| 88 | + |
| 89 | + steps: |
| 90 | + - name: Download artifacts |
| 91 | + uses: actions/download-artifact@v4 |
| 92 | + with: |
| 93 | + path: ${{ env.in }} |
| 94 | + pattern: "*-docs" |
| 95 | + merge-multiple: false |
| 96 | + |
| 97 | + - name: Extract archives |
| 98 | + run: | |
| 99 | + mkdir -p "$out" |
| 100 | + find "$in" -name artifact.tar \ |
| 101 | + | parallel tar \ |
| 102 | + --verbose \ |
| 103 | + --extract \ |
| 104 | + --file {} \ |
| 105 | + --directory "$out" |
132 | 106 |
|
133 | 107 | - name: Upload artifact
|
134 | 108 | uses: actions/upload-pages-artifact@v3
|
135 | 109 | with:
|
136 |
| - path: "docs-build" |
| 110 | + path: ${{ env.out }} |
137 | 111 |
|
| 112 | + deploy: |
| 113 | + name: Deploy |
| 114 | + runs-on: ubuntu-latest |
| 115 | + needs: combine |
| 116 | + |
| 117 | + permissions: |
| 118 | + pages: write # to deploy to Pages |
| 119 | + id-token: write # to verify the deployment originates from an appropriate source |
| 120 | + |
| 121 | + environment: |
| 122 | + name: github-pages |
| 123 | + url: ${{ steps.deployment.outputs.page_url }} |
| 124 | + |
| 125 | + steps: |
138 | 126 | - name: Deploy to GitHub Pages
|
139 | 127 | id: deployment
|
140 | 128 | uses: actions/deploy-pages@v4
|
0 commit comments