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

33 lines
508 B
Markdown

# Automate update via Git Hook
1. Navigate to the bare repository:
```bash
cd ~/git/asobi.git/hooks
```
2. Create `post-receive` Hook:
```bash
nano post-receive
```
3. Add script you want to run:
```bash
#!/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
```
4. Make the hook executable:
```
chmod +x post-receive
```