Last active
October 24, 2025 22:50
-
-
Save the-bokya/03332474bc69fc8082c3e92248db6750 to your computer and use it in GitHub Desktop.
Git auto build and deploy latest changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # $1 should be the directory for the git repo | |
| cd $1 | |
| git fetch | |
| git_diff=$(git diff origin/main) | |
| echo $git_diff | |
| if [ -z "$git_diff" ] | |
| then | |
| exit | |
| fi | |
| git reset --hard origin/main | |
| # $2 should be the path to the deploy script | |
| # e.g., "/root/scripts/deploy.sh" | |
| # you could just put stuff like npm install && npm run build && yada-yada here too | |
| $2 | |
| # add this to the crontab config | |
| # e.g., * * * * * /bin/bash -c '/root/scripts/push-to-deploy.sh "/root/repos/the-bokya.github.io" "/root/scripts/deploy.sh" &> "/root/logs/deploy/$(date).log"' | |
| # runs every minute (overkill, ik) and saves logs with date formatting |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment