Commit e0c7db7541
e0c7db7541d5f7a00cbfe0b2beb4282989f66a44
parent: b417650dbe
Unsigned
cmc <hello@cleberg.net> · 2026-02-10 18:49 UTC
implement GitLab CI
Layout: unified · split
.gitlab-ci-local/.gitignore
added
+2
| @@ -0,0 +1,2 @@ |
| 1 | * |
| 2 | !.gitignore |
.gitlab-ci.yml
added
+34
| @@ -0,0 +1,34 @@ |
| 1 | image: registry.gitlab.com/ccleberg/cleberg-net:latest |
| 2 | |
| 3 | stages: |
| 4 | - build |
| 5 | - deploy |
| 6 | |
| 7 | build-job: |
| 8 | stage: build |
| 9 | script: |
| 10 | - echo "Environment is ready. Running build..." |
| 11 | - ENV=prod uv run build.py <<< "r" |
| 12 | artifacts: |
| 13 | paths: |
| 14 | - .build/ |
| 15 | |
| 16 | deploy-job: |
| 17 | stage: deploy |
| 18 | environment: production |
| 19 | before_script: |
| 20 | - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' |
| 21 | - eval $(ssh-agent -s) |
| 22 | - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - |
| 23 | - mkdir -p ~/.ssh |
| 24 | - chmod 700 ~/.ssh |
| 25 | - ssh-keyscan $SERVER_IP >> ~/.ssh/known_hosts |
| 26 | - chmod 644 ~/.ssh/known_hosts |
| 27 | - | |
| 28 | echo "Host homelab-remote |
| 29 | HostName $SERVER_IP |
| 30 | User $SERVER_USER |
| 31 | Port 2169" > ~/.ssh/config |
| 32 | script: |
| 33 | - echo "Deploying via Python script..." |
| 34 | - ENV=prod uv run build.py <<< "r" |
.gitlab-ci.yml.bkp
added
+54
| @@ -0,0 +1,54 @@ |
| 1 | image: python:latest |
| 2 | |
| 3 | stages: |
| 4 | - build |
| 5 | - deploy |
| 6 | |
| 7 | variables: |
| 8 | TERM: xterm |
| 9 | HOMEBREW_NO_AUTO_UPDATE: "1" |
| 10 | |
| 11 | build-job: |
| 12 | stage: build |
| 13 | before_script: |
| 14 | # 1. Restore Homebrew if it was cached |
| 15 | - if [ -d ".linuxbrew/bin" ]; then |
| 16 | echo "Restoring Homebrew from cache..."; |
| 17 | mv .linuxbrew /home/linuxbrew; |
| 18 | fi |
| 19 | |
| 20 | # 2. Install Homebrew only if missing |
| 21 | - if [ ! -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then |
| 22 | apt-get update -qy && apt-get install -y curl git procps; |
| 23 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; |
| 24 | fi |
| 25 | |
| 26 | - eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)" |
| 27 | |
| 28 | # 3. Only install tools if they aren't already there |
| 29 | - command -v emacs >/dev/null 2>&1 || brew install emacs rsync uv minify |
| 30 | |
| 31 | # 4. Handle Emacs Repos (using a local project folder for easier caching) |
| 32 | - mkdir -p .emacs_repos |
| 33 | - "[ -d .emacs_repos/htmlize ] || git clone https://github.com/emacsorphanage/htmlize.git .emacs_repos/htmlize" |
| 34 | - "[ -d .emacs_repos/templatel ] || git clone https://github.com/emacs-love/templatel.git .emacs_repos/templatel" |
| 35 | - "[ -d .emacs_repos/weblorg ] || git clone https://github.com/emacs-love/weblorg.git .emacs_repos/weblorg" |
| 36 | script: |
| 37 | - echo "Compiling the site with Emacs and Weblorg..." |
| 38 | - yes r | ENV="prod" uv run build.py |
| 39 | - echo "Compile complete." |
| 40 | after_script: |
| 41 | - cp -r /home/linuxbrew/.linuxbrew .linuxbrew |
| 42 | artifacts: |
| 43 | paths: |
| 44 | - public/ |
| 45 | |
| 46 | deploy-job: |
| 47 | stage: deploy |
| 48 | environment: production |
| 49 | before_script: |
| 50 | - apt-get update -qy && apt-get install -y rsync |
| 51 | script: |
| 52 | - echo "Deploying application via rsync..." |
| 53 | # Example: rsync -azP public/ user@server:/var/www/html |
| 54 | - echo "Application successfully deployed." |
Dockerfile
added
+32
| @@ -0,0 +1,32 @@ |
| 1 | FROM python:3.12-slim |
| 2 | |
| 3 | ENV DEBIAN_FRONTEND=noninteractive \ |
| 4 | HOMEBREW_NO_AUTO_UPDATE=1 \ |
| 5 | PATH="/home/linuxbrew/.linuxbrew/bin:${PATH}" |
| 6 | |
| 7 | RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 8 | curl \ |
| 9 | git \ |
| 10 | procps \ |
| 11 | build-essential \ |
| 12 | ca-certificates \ |
| 13 | && rm -rf /var/lib/apt/lists/* |
| 14 | |
| 15 | RUN useradd -m -s /bin/bash linuxbrew && \ |
| 16 | echo "linuxbrew:linuxbrew" | chpasswd && \ |
| 17 | adduser linuxbrew sudo |
| 18 | |
| 19 | USER linuxbrew |
| 20 | WORKDIR /home/linuxbrew |
| 21 | |
| 22 | RUN /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 23 | |
| 24 | RUN brew install emacs rsync uv minify |
| 25 | |
| 26 | RUN mkdir -p ~/.config/emacs/.local/straight/repos && \ |
| 27 | git clone https://github.com/emacsorphanage/htmlize.git ~/.config/emacs/.local/straight/repos/htmlize && \ |
| 28 | git clone https://github.com/emacs-love/templatel.git ~/.config/emacs/.local/straight/repos/templatel && \ |
| 29 | git clone https://github.com/emacs-love/weblorg.git ~/.config/emacs/.local/straight/repos/weblorg |
| 30 | |
| 31 | USER root |
| 32 | WORKDIR /builds |
build.py
+8 −5
| @@ -253,19 +253,22 @@ def run_emacs_publish(dev_mode=True): |
| 253 | 253 | print("Running Emacs publish script (production)...") |
| 254 | 254 | result = subprocess.run( |
| 255 | 255 | ["emacs", "--script", "publish.el"], |
| 256 | | stdout=subprocess.DEVNULL, |
| 257 | | stderr=subprocess.DEVNULL, |
| 256 | stdout=subprocess.PIPE, |
| 257 | stderr=subprocess.PIPE, |
| 258 | 258 | text=True, |
| 259 | 259 | ) |
| 260 | 260 | |
| 261 | | # Fix to remove annoying cleberg-net.html file |
| 262 | | os.remove(".build/cleberg-net.html") |
| 263 | | |
| 264 | 261 | if result.returncode != 0: |
| 265 | 262 | print("Error running publish.el:") |
| 266 | 263 | print(result.stderr, file=sys.stderr) |
| 267 | 264 | sys.exit(1) |
| 268 | 265 | |
| 266 | annoying_file = Path(".build/cleberg-net.html") |
| 267 | if annoying_file.exists(): |
| 268 | os.remove(annoying_file) |
| 269 | else: |
| 270 | print("Warning: .build/cleberg-net.html not found, but Emacs exited successfully.") |
| 271 | |
| 269 | 272 | |
| 270 | 273 | def generate_sitemap(build_dir=".build", base_url="https://cleberg.net"): |
| 271 | 274 | """ |
publish.el
+8 −3
| @@ -1,8 +1,13 @@ |
| 1 | 1 | ;;; -*- lexical-binding: t -*- |
| 2 | 2 | ;; Explicitly load packages for Doom Emacs |
| 3 | | (add-to-list 'load-path "~/.config/emacs/.local/straight/repos/htmlize") |
| 4 | | (add-to-list 'load-path "~/.config/emacs/.local/straight/repos/weblorg") |
| 5 | | (add-to-list 'load-path "~/.config/emacs/.local/straight/repos/templatel") |
| 3 | (defvar site-lisp-base |
| 4 | (if (eq system-type 'darwin) |
| 5 | "~/.config/emacs/.local/straight/repos" ; macOS path |
| 6 | "/home/linuxbrew/.config/emacs/.local/straight/repos")) ; CI/Linux path |
| 7 | |
| 8 | (add-to-list 'load-path (expand-file-name "htmlize" site-lisp-base)) |
| 9 | (add-to-list 'load-path (expand-file-name "weblorg" site-lisp-base)) |
| 10 | (add-to-list 'load-path (expand-file-name "templatel" site-lisp-base)) |
| 6 | 11 | |
| 7 | 12 | (require 'htmlize) |
| 8 | 13 | (require 'weblorg) |