问题
I need to run the script on my server, when calling git push
from the local repository to the git gogs repository
#!/bin/sh
git pull origin test
source env/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
python manage.py migrate
python manage.py collectstatic --noinput
sudo systemctl restart gunicorn.service
sudo systemctl restart celery-worker.service
sudo systemctl restart celery-beat.service
Subtracted on the Internet - that you need to use git Hooks. Figured out how to edit hooks.
Question - how can I run a file from a server via SSH from git Hooks ???
ssh user@my.server
This does not work!
回答1:
You should not need ssh, considering the server-side hook will already execute on the (Git Gogs) server.
Make sure to put your script as an executable post-receive file, in one of your Gogs repositories bare repos.
And in that hook, do:
#!/bin/bash
echo "pull from non-bare repo"
unset GIT_DIR
cd /path/to/checkedout/repo
git --work-tree=. --git-dir=.git pull --no-rebase origin test
... rest of your script
Make sure that /path/to/checkedout/repo is a clone of one of your Gogs repo.
来源:https://stackoverflow.com/questions/55655874/how-to-call-a-script-from-the-server-when-git-push-to-the-git-gogs-repository