coding-memo/memo/git-hook.md
2025-03-14 16:37:13 +09:00

508 B

Automate update via Git Hook

  1. Navigate to the bare repository:
cd ~/git/asobi.git/hooks
  1. Create post-receive Hook:
nano post-receive
  1. Add script you want to run:
#!/bin/bash

# Deployment directory
DEPLOY_DIR="/home/nik/repo/asobi"

# Navigate to the deployment directory
cd $DEPLOY_DIR

# Pull the latest changes
git pull origin main

# Restart the service
sudo systemctl restart asobi-web.service
  1. Make the hook executable:
chmod +x post-receive