feat: Add a Forgejo Actions pipeline

Added a Forgejo Actions CI/CD pipeline to supersede the manual deploy.sh,
automating builds and deployments on push.
This commit is contained in:
Matthew Binning 2026-03-22 14:06:34 -07:00
parent 0f7e0b6432
commit 35ecd1d0b7
3 changed files with 41 additions and 16 deletions

View file

@ -0,0 +1,17 @@
name: Build and Deploy
on:
push:
branches:
- master
- develop
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy
run: nix shell nixpkgs#mdbook --command ./deploy.sh local

View file

@ -9,7 +9,7 @@ mdbook build
# Usage information # Usage information
usage() { usage() {
printf "Usage: %s [staging|prod]\n\n staging - Deploy to local staging environment (/srv/www/stage.binning.net)\n prod - Deploy to production server via SSH (www.binning.net)\n\nExample:\n %s staging\n %s prod\n" "$0" "$0" "$0" printf "Usage: %s [staging|prod|local]\n\n staging - Deploy to local staging environment (/srv/www/stage.binning.net)\n prod - Deploy to production server via SSH (www.binning.net)\n local - Deploy directly to /srv/www/binning.net (used by Forgejo CI runner)\n\nExample:\n %s staging\n %s prod\n %s local\n" "$0" "$0" "$0" "$0"
exit 1 exit 1
} }
@ -46,7 +46,7 @@ case $ENV in
# SSH details # SSH details
REMOTE_HOST="crossbox" REMOTE_HOST="crossbox"
REMOTE_USER="m3b" REMOTE_USER="brimlock"
REMOTE_PATH="/srv/www/binning.net" REMOTE_PATH="/srv/www/binning.net"
# Check if SSH key is set up # Check if SSH key is set up
@ -55,16 +55,25 @@ case $ENV in
fi fi
# Deploy website files via rsync over SSH # Deploy website files via rsync over SSH
# Using just the host from SSH config without user@ prefix
printf "Deploying website files...\n" printf "Deploying website files...\n"
ssh ${REMOTE_HOST} "mkdir -p /tmp/${REMOTE_PATH}" ssh ${REMOTE_USER}@${REMOTE_HOST} "mkdir -p /tmp/${REMOTE_PATH}"
rsync -avz --delete ${DEPLOY_FILES} ${REMOTE_HOST}:/tmp/${REMOTE_PATH}/ rsync -avz --delete main/ blog ${REMOTE_USER}@${REMOTE_HOST}:/tmp/${REMOTE_PATH}/
# Set proper permissions and move config on remote server ssh ${REMOTE_USER}@${REMOTE_HOST} "sudo rsync -avz --delete /tmp/${REMOTE_PATH}/ ${REMOTE_PATH}/ && \
ssh ${REMOTE_HOST} "sudo rsync -avz --delete /tmp/${REMOTE_PATH}/ ${REMOTE_PATH} && \
sudo chown -R nginx:nginx ${REMOTE_PATH}/ && \ sudo chown -R nginx:nginx ${REMOTE_PATH}/ && \
printf 'Content deployed.\n'" printf 'Content deployed.\n'"
printf "✓ Production deployment complete!\n\nNginx configuration is managed by the nixos-config flake (hosts/crossbox/nginx.nix).\n" "${REMOTE_HOST}" printf "✓ Production deployment complete!\n\nNginx configuration is managed by the nixos-config flake (hosts/crossbox/nginx.nix).\n"
;;
local)
printf "Deploying locally to production path...\n"
LOCAL_PATH="/srv/www/binning.net"
printf "Deploying website files...\n"
rsync -av --delete main/ blog ${LOCAL_PATH}/
printf "✓ Local deployment complete!\n Files deployed to: %s\n" "${LOCAL_PATH}"
;; ;;
*) *)

View file

@ -1,9 +1,7 @@
x 2026-03-22 Add a folder to hold the nginx/nix files and deploy it properly. (A) Add a Forgejo pipeline to supersede deploy.sh.
(B) Add a Forgejo pipeline to supersede deploy.sh. @Cline (B) Move the resume to the private section and add the lock symbol.
(C) Move the resume to the private section and add the lock symbol. @Cline (C) Remove the one line descriptions from the menu.
Remove the one line descriptions from the menu. @Cline (D) Reduce the CSS where possible. Match my website's theme to align with mdbook's theme.
Reduce the CSS where possible. Match my website's theme to align with mdbook's theme. @Cline
Theme Forgejo where possible to match the theme. @Cline
Personalize the index page. Personalize the index page.
Change the title of the Blog. Change the title of the Blog.
@ -43,3 +41,4 @@ x Create a "minimal" content set to test building and deployment without the ent
x Import Abby's Binning Family Menu @Cline x Import Abby's Binning Family Menu @Cline
x Fix anchors (relative links) showing in mdbook's sidebar. x Fix anchors (relative links) showing in mdbook's sidebar.
x Create a minimal "Menu" (food menu) page on the main website, which has a selection of line items from the recipe book. @Cline x Create a minimal "Menu" (food menu) page on the main website, which has a selection of line items from the recipe book. @Cline
x 2026-03-22 Add a folder to hold the nginx/nix files and deploy it properly.