From 7437079fc335f31c92aecf7cb2613fa708f6b084 Mon Sep 17 00:00:00 2001 From: Jonas Kuball Date: Tue, 3 Dec 2024 22:29:04 +0100 Subject: [PATCH] first try to use github pages --- .github/workflows/book.yaml | 19 +++++++++++ .gitignore | 6 ++++ book.toml | 8 +++++ cells/code/README.md | 3 -- cells/code/challenges/day-01-part2.md | 1 + cells/code/challenges/day-02-part2.md | 1 + cells/repository/configs.nix | 45 +++++++++++++++++++++++++++ cells/repository/devshells.nix | 8 +++++ docs/SUMMARY.md | 13 ++++++++ 9 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/book.yaml create mode 100644 book.toml delete mode 100644 cells/code/README.md create mode 100644 cells/code/challenges/day-01-part2.md create mode 100644 cells/code/challenges/day-02-part2.md create mode 100644 docs/SUMMARY.md diff --git a/.github/workflows/book.yaml b/.github/workflows/book.yaml new file mode 100644 index 0000000..a2e09df --- /dev/null +++ b/.github/workflows/book.yaml @@ -0,0 +1,19 @@ +jobs: + deploy: + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: nixbuild/nix-quick-install-action@v29 + - run: nix develop .#book -c mdbook build ./. + - if: ${{ github.ref == 'refs/heads/main' }} + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/book +name: Deploy to GitHub Pages +'on': + push: + branches: + - main diff --git a/.gitignore b/.gitignore index 094e2c1..94f1bd2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,11 @@ result .cache/ .data/ +# mdbook +docs/book/ +docs/cells/ +docs/index.html +docs/README.md + # nixago: ignore-linked-files /treefmt.toml diff --git a/book.toml b/book.toml new file mode 100644 index 0000000..0845de7 --- /dev/null +++ b/book.toml @@ -0,0 +1,8 @@ +[book] +language = "en" +multilingual = false +src = "docs" +title = "Advent of Code 2024 - A report." + +[build] +build-dir = "docs/book" diff --git a/cells/code/README.md b/cells/code/README.md deleted file mode 100644 index 4168d98..0000000 --- a/cells/code/README.md +++ /dev/null @@ -1,3 +0,0 @@ -This cell contains a single block which houses all code challenges. - -They all share an instance of nixpkgs, as imported in the (cli invisible) block `./nixpkgs`. diff --git a/cells/code/challenges/day-01-part2.md b/cells/code/challenges/day-01-part2.md new file mode 100644 index 0000000..d5b0142 --- /dev/null +++ b/cells/code/challenges/day-01-part2.md @@ -0,0 +1 @@ +# Part 2 diff --git a/cells/code/challenges/day-02-part2.md b/cells/code/challenges/day-02-part2.md new file mode 100644 index 0000000..d5b0142 --- /dev/null +++ b/cells/code/challenges/day-02-part2.md @@ -0,0 +1 @@ +# Part 2 diff --git a/cells/repository/configs.nix b/cells/repository/configs.nix index 4185af9..8011667 100644 --- a/cells/repository/configs.nix +++ b/cells/repository/configs.nix @@ -18,4 +18,49 @@ in { includes = ["*.nix"]; }; }; + + github-workflow-book = mkNixago { + output = ".github/workflows/book.yaml"; + hook.mode = "copy"; + + data = { + name = "Deploy to GitHub Pages"; + on.push.branches = ["main"]; + + jobs.deploy = { + runs-on = "ubuntu-latest"; + concurrency.group = "\${{ github.workflow }}-\${{ github.ref }}"; + steps = [ + { uses = "actions/checkout@v4"; } + { uses = "nixbuild/nix-quick-install-action@v29"; } + { run = "nix develop .#book -c mdbook build ./."; } + { + uses = "peaceiris/actions-gh-pages@v4"; + "if" = "\${{ github.ref == 'refs/heads/main' }}"; + "with" = { + "github_token" = "\${{ secrets.GITHUB_TOKEN }}"; + "publish_dir" = "./docs/book"; + }; + } + ]; + }; + }; + }; + + mdbook = mkNixago { + output = "book.toml"; + hook.mode = "copy"; + + packages = with pkgs; [ mdbook ]; + + data = { + book = { + title = "Advent of Code 2024 - A report."; + language = "en"; + multilingual = false; + src = "docs"; + }; + build.build-dir = "docs/book"; + }; + }; } diff --git a/cells/repository/devshells.nix b/cells/repository/devshells.nix index 7820795..e77528e 100644 --- a/cells/repository/devshells.nix +++ b/cells/repository/devshells.nix @@ -11,4 +11,12 @@ in { treefmt ]; }; + + book = mkShell { + name = "AoC 2024: Book"; + + nixago = with cell.configs; [ + mdbook + ]; + }; } diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md new file mode 100644 index 0000000..9556364 --- /dev/null +++ b/docs/SUMMARY.md @@ -0,0 +1,13 @@ +# Summary + +[Introduction](../README.md) + +# Challenges + +- [Day 1]() + - [Part 1](../cells/code/challenges/day-01-part1.md) + - [Part 2](../cells/code/challenges/day-01-part2.md) + +- [Day 2]() + - [Part 1](../cells/code/challenges/day-01-part1.md) + - [Part 2](../cells/code/challenges/day-01-part2.md)