To standardize code-update deploys.
Note that the "callee" scripts in this repository are not called directly. Instead -- the last line of the "caller" script should be:
source /path/to/the_CALLEE.sh
This is the script to call for the newer projects that do have a pyproject.toml file.
Features:
- updates permissions and groups
- runs
git pull - auto-updates the active venv
- runs tests after the update (locally and on dev -- intentionally not on prod)
- runs django's
collectstaticcommand if aSTATIC_WEB_DIR_PATHenvar is detected - optionally runs in
--permissions_onlymode
Usage:
$ bash ./specific_project_caller.sh
or
$ bash ./specific_project_caller.sh --permissions_only
This is a script to call for the older projects that do not have a pyproject.toml file.
does chmod, chgrp, git pull, and optionally collectstatic and touch restart, based on envars in a caller script
-(-)permissions_only stop script after updating permissions and groups
-(-)pip_deploy [requirements] additionally make venv, install requirements specified in [requirements], and set symlink
-h/--help show this help and exit"
This is a script to call for the older projects that do not have a pyproject.toml file that offers more capabilities.
Note that it has not been extensively tested. If you use it successfully, let the team know.
code_update_script_NEW.sh (callee): resets group/perms on key paths, git pulls the repo, optionally creates/symlinks a new venv via --pip_deploy <requirements.txt> or --uv_deploy <requirements.txt>, optionally runs collectstatic, then touches the restart file (run it by sourceing it from a per-project caller script after setting the required envars).
Most of the envars in a caller script are set using the format:
VAR_NAME="var_value"
However, the uv_tomlized_code_update_script_CALLEE.sh script accepts an optional $URLS_TO_CHECK variable, which should be set using the format:
URLS_TO_CHECK=(
"https://url_1"
"https://url_2"
)
Tests are auto-run on dev-servers, but not on prod-servers, to minimize the chance that a test may write to the production database in an unintended way.
On a successful test-run, the script output will simply indicate that the tests were successful. On any failures, the full test-output logging will be shown.
The command below:
## ensure group inheritance for newly-created files/dirs under this tree
find "$dir_path" -type d -exec sudo /bin/chmod g+s {} +
...was removed from the uv_tomlized_code_update_script_CALLEE.sh script -- in the permissions-update-for-loop, because it could generate a "too many arguments" error on some projects with lots of directories.
That's ok, because the sticky-bit it set was a one-time operation. Feel free to run it manually from the command-line, on a new stuff-directory, if you see that newly-created files/dirs are not inheriting the expected group, and find that annoying. (But it's not necessary -- the regular code-update scripts will correct the groups.)