diff --git a/.github/workflows/build-and-deploy.yaml b/.github/workflows/build-and-deploy.yaml new file mode 100644 index 0000000..750879b --- /dev/null +++ b/.github/workflows/build-and-deploy.yaml @@ -0,0 +1,58 @@ +name: Build and Deploy + +on: + push: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +jobs: + build: + name: Build and Deploy Site + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 23 + + - name: Restore cache + uses: actions/cache@v4 + with: + path: | + node_modules + .image-cache + key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Build with Node + run: | + npm ci + npx @11ty/eleventy + + - name: Deploy to Neocities + uses: bcomnes/deploy-to-neocities@v2 + with: + api_token: ${{ secrets.NEOCITIES_API_KEY }} + cleanup: true + dist_dir: _site + + - name: Deploy to Bunny + uses: R-J-dev/bunny-deploy@v2.0.6 + with: + access-key: ${{ secrets.BUNNY_ACCESS_KEY }} + directory-to-upload: _site + storage-endpoint: "https://storage.bunnycdn.com" + storage-zone-name: "buttonkin" + storage-zone-password: ${{ secrets.BUNNY_STORAGE_ZONE_PASSWORD }} + concurrency: "5" + enable-delete-action: true + enable-purge-pull-zone: true + pull-zone-id: "4605820" + replication-timeout: "15000" diff --git a/.gitignore b/.gitignore index 0af8aff..9ee6592 100644 --- a/.gitignore +++ b/.gitignore @@ -131,11 +131,6 @@ dist .yarn/install-state.gz .pnp.* -# ---> Nix -# Ignore build outputs from performing a nix-build or `nix build` command -result -result-* - # ---> Eleventy # Built site _site diff --git a/bin/build b/bin/build deleted file mode 100644 index e1f9fc1..0000000 --- a/bin/build +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -rm -rf _site -npx @11ty/eleventy diff --git a/bin/dryrun b/bin/dryrun deleted file mode 100644 index b22a891..0000000 --- a/bin/dryrun +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -npx @11ty/eleventy --dryrun --quiet diff --git a/bin/lint b/bin/lint deleted file mode 100755 index b23b856..0000000 --- a/bin/lint +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env nix-shell -#! nix-shell -i bash -p biome - -biome \ - format \ - --write \ - --no-errors-on-unmatched \ - --files-ignore-unknown=true \ - "./src" diff --git a/bin/screenshot b/bin/screenshot deleted file mode 100755 index 65a94c9..0000000 --- a/bin/screenshot +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env nix-shell -#! nix-shell -i bash -p chromium - -BASE_URL="http://localhost:8080" -OUTPUT_DIR="screenshots" - -if [ $# -eq 0 ]; then - echo "Usage: $0 [output-filename]" - exit 1 -fi - -PATH_TO_SCREENSHOT="$1" -FULL_URL="${BASE_URL}${PATH_TO_SCREENSHOT}" -PAGE_NAME=$(echo $PATH_TO_SCREENSHOT | sed 's/\//-/g' | sed 's/^-//') -if [ "$PAGE_NAME" = "" ]; then - PAGE_NAME="home" -fi -OUTPUT_FILE="${2:-${OUTPUT_DIR}/${PAGE_NAME}}" -# Add .png extension if not present -if [[ "$OUTPUT_FILE" != *.png ]]; then - OUTPUT_FILE="${OUTPUT_FILE}.png" -fi - -rm "$OUTPUT_FILE" - -# Create output directory if it doesn't exist -mkdir -p "$(dirname "$OUTPUT_FILE")" - -echo "Taking screenshot of $FULL_URL" -echo "Saving to $OUTPUT_FILE" - -chromium \ - --headless \ - --disable-gpu \ - --no-sandbox \ - --screenshot="$OUTPUT_FILE" \ - --window-size=1280,4000 \ - --hide-scrollbars \ - --default-background-color=FFFFFF \ - --virtual-time-budget=5000 \ - --run-all-compositor-stages-before-draw \ - "$FULL_URL" \ - --remote-debugging-port=9222 2>/dev/null & -CHROME_PID=$! - -# Wait for the screenshot to be created and reach its final size -while ! [ -f "$OUTPUT_FILE" ]; do sleep 0.1; done -PREV_SIZE=0 -CURRENT_SIZE=$(stat -c%s "$OUTPUT_FILE" 2>/dev/null || echo 0) -while [ $CURRENT_SIZE -ne $PREV_SIZE ]; do - PREV_SIZE=$CURRENT_SIZE - sleep 0.5 - CURRENT_SIZE=$(stat -c%s "$OUTPUT_FILE" 2>/dev/null || echo 0) -done - -# Kill the Chromium process -kill $CHROME_PID 2>/dev/null || true - -echo "Screenshot saved to $OUTPUT_FILE" diff --git a/bin/serve b/bin/serve deleted file mode 100755 index 20b47c2..0000000 --- a/bin/serve +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -rm -rf _site -npx @11ty/eleventy --serve --incremental --quiet diff --git a/default.nix b/default.nix deleted file mode 100644 index ac60605..0000000 --- a/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -(import - ( - let - flake-compat = fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/12c64ca55c1014cdc1b16ed5a804aa8576601ff2.tar.gz"; - sha256 = "0jm6nzb83wa6ai17ly9fzpqc40wg1viib8klq8lby54agpl213w5"; - }; - in - "${flake-compat}/default.nix" - ) - { - src = ./.; - } -).defaultNix.packages.${builtins.currentSystem}.site diff --git a/flake.nix b/flake.nix index 612cbcf..d7e9686 100644 --- a/flake.nix +++ b/flake.nix @@ -10,147 +10,27 @@ forAllSystems = nixpkgs.lib.genAttrs systems; in { - packages = forAllSystems ( - system: - let - pkgs = import nixpkgs { system = system; }; - dependencies = with pkgs; [ nodejs_23 ]; - nodeModules = pkgs.buildNpmPackage { - pname = "buttonkin-dependencies"; - version = "1.0.0"; - src = pkgs.runCommand "source" { } '' - mkdir -p $out - cp ${./package.json} $out/package.json - cp ${./package-lock.json} $out/package-lock.json - ''; - npmDepsHash = "sha256-FGMvzbHIkV/oOdqD7X3ULn0Vdi+1Exmxw+nmE5kTc6s="; - installPhase = "mkdir -p $out && cp -r node_modules $out/"; - dontNpmBuild = true; - }; - - makeScript = - name: - let - baseScript = pkgs.writeScriptBin name (builtins.readFile ./bin/${name}); - patchedScript = baseScript.overrideAttrs (old: { - buildCommand = "${old.buildCommand}\n patchShebangs $out"; - }); - in - pkgs.symlinkJoin { - name = name; - paths = [ patchedScript ] ++ dependencies; - buildInputs = [ pkgs.makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/${name} --prefix PATH : $out/bin - ''; - }; - - scriptNames = builtins.attrNames (builtins.readDir ./bin); - scriptPackages = nixpkgs.lib.genAttrs scriptNames makeScript; - - sitePackage = pkgs.stdenv.mkDerivation { - name = "buttonkin"; - src = ./.; - buildInputs = dependencies ++ [ nodeModules ]; - - buildPhase = '' - mkdir -p $TMPDIR/build_dir - cd $TMPDIR/build_dir - - cp -r $src/* . - cp -r $src/.image-cache . - chmod -R a+rwX .image-cache - cp $src/.eleventy.js . - - ln -s ${nodeModules}/node_modules node_modules - - mkdir -p src/_data - chmod -R +w src/_data - - ${scriptPackages.build}/bin/build - ''; - - installPhase = '' - mkdir -p $out - mv $TMPDIR/build_dir/_site $out/ - mv $TMPDIR/build_dir/.image-cache $out/ - ''; - - dontFixup = true; - }; - - allPackages = { - site = sitePackage; - nodeModules = nodeModules; - } // scriptPackages; - in - allPackages - ); - - defaultPackage = forAllSystems (system: self.packages.${system}.site); - devShells = forAllSystems ( system: let pkgs = import nixpkgs { system = system; }; dependencies = with pkgs; [ - biome nodejs_23 ]; - - nodeModules = pkgs.buildNpmPackage { - pname = "buttonkin-dependencies"; - version = "1.0.0"; - src = pkgs.runCommand "source" { } '' - mkdir -p $out - cp ${./package.json} $out/package.json - cp ${./package-lock.json} $out/package-lock.json - ''; - npmDepsHash = "sha256-FGMvzbHIkV/oOdqD7X3ULn0Vdi+1Exmxw+nmE5kTc6s="; - installPhase = "mkdir -p $out && cp -r node_modules $out/"; - dontNpmBuild = true; - }; - - makeScript = - name: - let - baseScript = pkgs.writeScriptBin name (builtins.readFile ./bin/${name}); - patchedScript = baseScript.overrideAttrs (old: { - buildCommand = "${old.buildCommand}\n patchShebangs $out"; - }); - in - pkgs.symlinkJoin { - name = name; - paths = [ patchedScript ] ++ dependencies; - buildInputs = [ pkgs.makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/${name} --prefix PATH : $out/bin - ''; - }; - - scriptNames = builtins.attrNames (builtins.readDir ./bin); - scriptPackages = nixpkgs.lib.genAttrs scriptNames makeScript; - - scriptPackageList = builtins.attrValues scriptPackages; in { default = pkgs.mkShell { - buildInputs = dependencies ++ scriptPackageList; + buildInputs = dependencies; shellHook = '' - rm -rf node_modules - ln -s ${nodeModules}/node_modules node_modules cat <