Skip to content

Instantly share code, notes, and snippets.

@singiamtel
Created February 2, 2024 14:13
Show Gist options
  • Save singiamtel/b80e8da85671110d3a7ed279d40ce102 to your computer and use it in GitHub Desktop.
Save singiamtel/b80e8da85671110d3a7ed279d40ce102 to your computer and use it in GitHub Desktop.
Basic deploy script to integrate with GH actions. Currently used in crob.at
#!/bin/bash
# Original author: https://github.com/pkmn/ai/blob/main/deploy
set -euxo pipefail
# Save our current commit to use for comparison later
HEAD=$(git rev-parse HEAD)
# Pull down latest code
git pull origin master
# Update dependencies if package.json has changed
# This can break if:
# - You mess with the server repo manually
# - Your repo has broken dependencies/devDependencies separation
git diff --quiet $HEAD package.json >/dev/null ||
npm install --omit=dev --silent
npm run build
pm2 restart 0 # Change this to your pm2 process name
# Reload proxy server if the config has changed
git diff --quiet $HEAD infra/Caddyfile ||
sudo systemctl reload caddy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment