diff --git a/.forgejo/workflows/book-pr.yaml b/.forgejo/workflows/book-pr.yaml new file mode 100644 index 0000000..cde53e6 --- /dev/null +++ b/.forgejo/workflows/book-pr.yaml @@ -0,0 +1,58 @@ +name: "Book - PR" + +on: + pull_request: + types: + - opened + - reopened + - synchronize + +concurrency: + group: page-preview + cancel-in-progress: false + +jobs: + createPreview: + runs-on: nix + env: + SITE_ORIGIN: + "https://${{ forge.event.repository.owner.username + }}.preview.codeberg.page" + SITE_BASEPATH: + "/${{ forge.event.repository.name }}@${{ forge.event.number }}/" + steps: + - uses: actions/checkout@v4 + - uses: https://codeberg.org/icewind/attic-action@v1 + with: + name: link + instance: https://cache.icewind.link + authToken: "${{ secrets.ATTIC_TOKEN }}" + - name: Build + run: | + # git-pages/action doesn't like symlinks + cp -r $(nix build .#haze-book --print-out-paths --no-link) dist + - name: "Deploy Site" + uses: https://code.forgejo.org/actions/git-pages@v2 + with: + site: "${{ env.SITE_ORIGIN }}${{ env.SITE_BASEPATH }}" # + token: "${{ forge.token }}" # + source: "dist/" # + - name: "Find comment" + uses: "https://github.com/peter-evans/find-comment@v4" # + id: comment + with: + issue-number: ${{ forge.event.number }} # + body-includes: "" # + - name: "Create or update comment" + uses: "https://github.com/peter-evans/create-or-update-comment@v5" # + with: + issue-number: ${{ forge.event.number }} # + comment-id: "${{ steps.comment.outputs.comment-id }}" # + edit-mode: "replace" + body: |- + # Pull request preview ready! + + The Preview of commit ${{ forge.event.pull_request.head.sha }} has been created. + You can find it here: ${{ env.SITE_ORIGIN }}${{ env.SITE_BASEPATH }} + + diff --git a/.forgejo/workflows/book.yaml b/.forgejo/workflows/book.yaml new file mode 100644 index 0000000..05b4f11 --- /dev/null +++ b/.forgejo/workflows/book.yaml @@ -0,0 +1,29 @@ +name: "Book" + +on: + push: + branches: + - main + +jobs: + preview: + runs-on: nix + env: + SITE_ORIGIN: "${{forge.event.repository.owner.username}}.codeberg.page" + SITE_BASEPATH: "/${{forge.event.repository.name}}/" + steps: + - uses: actions/checkout@v4 + - uses: https://codeberg.org/icewind/attic-action@v1 + with: + name: link + instance: https://cache.icewind.link + authToken: "${{ secrets.ATTIC_TOKEN }}" + - name: Build + run: | + # git-pages/action doesn't like symlinks + cp -r $(nix build .#haze-book --print-out-paths --no-link) dist + - uses: https://codeberg.org/git-pages/action@v2 + with: + site: https://${{ env.SITE_ORIGIN }}${{ env.SITE_BASEPATH }} + token: ${{ forge.token }} + source: dist/ diff --git a/flake.nix b/flake.nix index bde0f45..b9efaaa 100644 --- a/flake.nix +++ b/flake.nix @@ -55,6 +55,7 @@ "haze-image-php-8.2" = pkgs: pkgs.haze-image-php-82; "haze-image-php-8.1" = pkgs: pkgs.haze-image-php-81; "haze-image-php-8.0" = pkgs: pkgs.haze-image-php-80; + haze-book = pkgs: pkgs.haze-book; }; tools = pkgs: diff --git a/nix/book.nix b/nix/book.nix new file mode 100644 index 0000000..a1b1442 --- /dev/null +++ b/nix/book.nix @@ -0,0 +1,20 @@ +{ + mdbook, + stdenv, + ... +}: +stdenv.mkDerivation { + name = "haze-book"; + src = ../book; + + nativeBuildInputs = [mdbook]; + + buildPhase = '' + mdbook build + ''; + + installPhase = '' + mkdir -p $out + cp -r book/* $out/ + ''; +} diff --git a/nix/overlay.nix b/nix/overlay.nix index 276b70e..030b559 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -6,4 +6,5 @@ final: prev: { haze-image-php-82 = final.callPackage ./image/haze.nix {php = final.php82;}; haze-image-php-81 = final.callPackage ./image/haze.nix {php = final.php81;}; haze-image-php-80 = final.callPackage ./image/haze.nix {php = final.php80;}; + haze-book = final.callPackage ./book.nix {}; }