Created
January 7, 2026 22:15
-
-
Save birkin/e2ef184ca9da09ff2bcf873b30b72a74 to your computer and use it in GitHub Desktop.
backup CALLEE file for uv-toml projects
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 | |
| ## assumes `uv` is installed and available in PATH | |
| ## Usage: `bash ./CALLER.sh`, which sets vars and then runs `source /path/to/CALLEE.sh` | |
| ## helper code ------------------------------------------------------ | |
| ## function for calls below | |
| function reset_group_and_permissions () { | |
| if [[ -n $STATIC_WEB_DIR_PATH ]]; then | |
| path_array=( $LOG_DIR_PATH $STUFF_DIR_PATH $STATIC_WEB_DIR_PATH ) | |
| else | |
| path_array=( $LOG_DIR_PATH $STUFF_DIR_PATH ) | |
| fi | |
| for i in "${path_array[@]}" | |
| do | |
| echo "processing directory: " $i | |
| sudo /bin/chgrp -R $GROUP $i | |
| sudo /bin/chmod -R g=rwX $i | |
| ## ensure group inheritance for newly-created files/dirs under this tree | |
| find "$i" -type d -exec sudo /bin/chmod g+s {} + | |
| done | |
| } | |
| ## main code -------------------------------------------------------- | |
| ## reset INITIAL group and permissions ---------- | |
| echo ":: running INITIAL group and permissions update..."; echo " " | |
| reset_group_and_permissions | |
| echo "---"; echo " " | |
| ## update app ----------------------------------- | |
| echo ":: running git pull..."; echo " " | |
| cd $PROJECT_DIR_PATH | |
| git pull | |
| echo "---"; echo " " | |
| ## update any python packages ------------------- | |
| echo "running uv sync..."; echo " " | |
| uv sync --locked --group $UV_GROUP | |
| echo "---"; echo " "; echo " " | |
| ## run collectstatic ---------------------------- | |
| if [[ -n $STATIC_WEB_DIR_PATH ]]; then | |
| echo "running collectstatic..." | |
| uv run ./manage.py collectstatic --noinput | |
| echo "---"; echo " " | |
| fi | |
| ## reset FINAL group and permissions ----------- | |
| echo "running final ownership and permissions update..."; echo " " | |
| reset_group_and_permissions | |
| echo "---"; echo " " | |
| ## make it real | |
| if [[ -n $TOUCH_PATH ]]; then | |
| echo "touching the restart file..." | |
| touch $TOUCH_PATH | |
| sleep 1 | |
| echo "---"; echo " " | |
| fi | |
| ## run tests ------------------------------------ | |
| echo ":: running tests..."; echo " " | |
| cd $PROJECT_DIR_PATH | |
| if uv run ./run_tests.py; then | |
| echo "Tests passed successfully" | |
| else | |
| echo "ERROR: Tests failed with exit code $?" | |
| echo "Please check the test output above for details" | |
| echo "Continuing with deployment despite test failure..." | |
| fi | |
| echo "---"; echo " " | |
| ## check urls ----------------------------------- | |
| if [[ -n $URLS_TO_CHECK ]]; then | |
| echo "running curl-check..." | |
| for url in "${URLS_TO_CHECK[@]}" | |
| do | |
| echo " "; echo "checking url: " $url | |
| HTTP_CODE=$(curl --head -s -o /dev/null -w "%{http_code}" --max-time 5 $url) | |
| if [[ $HTTP_CODE == "200" ]]; then | |
| echo "curl-check: good! (HTTP $HTTP_CODE)" | |
| else | |
| echo "curl-check: FAILED - received HTTP $HTTP_CODE (expected 200)" | |
| fi | |
| done | |
| else | |
| echo "no urls to curl..." | |
| fi | |
| echo "---"; echo " " | |
| ## that's it! ----------------------------------- | |
| echo "DEPLOY-COMPLETE"; echo " "; echo "--------------------"; echo " " | |
| ## [END] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment