|
1 | 1 | #!/bin/bash
|
2 |
| -# |
| 2 | +# ----------------------------------------------------------------------------- |
3 | 3 | # This script updates template-application-flask in your project. Run
|
4 | 4 | # This script from your project's root directory.
|
| 5 | +# |
| 6 | +# Positional parameters: |
| 7 | +# TARGET_VERSION (optional) – the version of template-application-flask to upgrade to. |
| 8 | +# Defaults to main. |
| 9 | +# ----------------------------------------------------------------------------- |
5 | 10 | set -euo pipefail
|
6 | 11 |
|
7 |
| -SCRIPT_DIR=$(dirname $0) |
| 12 | +TARGET_VERSION=${1:-"main"} |
| 13 | + |
| 14 | +CURRENT_VERSION=$(cat .template-flask-version) |
| 15 | + |
| 16 | +echo "Clone template-application-flask" |
| 17 | +git clone https://github.com/navapbc/template-application-flask.git |
| 18 | + |
| 19 | +echo "Creating patch" |
| 20 | +cd template-application-flask |
| 21 | +git checkout $TARGET_VERSION |
| 22 | + |
| 23 | +# Get version hash to update .template-flask-version after patch is successful |
| 24 | +TARGET_VERSION_HASH=$(git rev-parse HEAD) |
| 25 | + |
| 26 | +# Note: Keep this list in sync with the files copied in install-template.sh |
| 27 | +INCLUDE_PATHS=" \ |
| 28 | + github \ |
| 29 | + .dockleconfig \ |
| 30 | + .hadolint.yaml \ |
| 31 | + app \ |
| 32 | + docker-compose.yml \ |
| 33 | + docs" |
| 34 | +git diff $CURRENT_VERSION $TARGET_VERSION -- $INCLUDE_PATHS >patch |
| 35 | +cd - |
| 36 | + |
| 37 | +echo "Applying patch" |
| 38 | +# Note: Keep this list in sync with the removed files in install-template.sh |
| 39 | +EXCLUDE_OPT="--exclude=.github/workflows/template-only-*" |
| 40 | +git apply $EXCLUDE_OPT --allow-empty template-application-flask/patch |
| 41 | + |
| 42 | +echo "Saving new template version to .template-application-flask" |
| 43 | +echo $TARGET_VERSION_HASH >.template-flask-version |
8 | 44 |
|
9 |
| -echo "Install template" |
10 |
| -$SCRIPT_DIR/install-template.sh |
| 45 | +echo "Clean up template-application-flask folder" |
| 46 | +rm -fr template-application-flask |
0 commit comments