Files
indiekit-server/.github/workflows/deploy.yml
2026-03-07 18:57:43 +01:00

63 lines
2.0 KiB
YAML

name: Deploy Indiekit Blog
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm ci
- name: Build (if needed)
run: |
# Add build steps if your project requires them
echo "No build step required"
- name: Deploy to FreeBSD host and jail
uses: appleboy/ssh-action@v0.1.10
with:
host: ${{ secrets.FREEBSD_HOST }}
username: ${{ secrets.FREEBSD_DEPLOY_USER }}
key: ${{ secrets.FREEBSD_DEPLOY_SSH_KEY }}
port: 222
script: |
set -eu
# Update code and dependencies as indiekit user inside the jail.
sudo bastille cmd node sh -lc 'cd /usr/local/indiekit && su -l indiekit -c "git pull origin main && npm ci"'
# Restart asynchronously to avoid hanging SSH sessions when rc scripts keep stdout open.
sudo bastille cmd node sh -lc 'nohup service indiekit restart >/tmp/indiekit-restart.log 2>&1 </dev/null &'
sleep 3
if sudo bastille cmd node pgrep -f "indiekit serve" >/dev/null 2>&1; then
echo "Indiekit restart triggered and process is running."
else
echo "Indiekit process not found after restart."
sudo bastille cmd node sh -lc 'tail -n 80 /tmp/indiekit-restart.log || true'
exit 1
fi
# Optionally reload nginx on web jail
# - name: Reload nginx
# uses: appleboy/ssh-action@v0.1.10
# with:
# host: ${{ secrets.FREEBSD_WEB_HOST }}
# username: ${{ secrets.FREEBSD_WEB_USER }}
# key: ${{ secrets.FREEBSD_WEB_SSH_KEY }}
# port: ${{ secrets.FREEBSD_WEB_PORT }}
# script: sudo service nginx reload