-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make update-template.sh more robust to deletions and changes to files (…
…#217) ## Ticket Resolves #196 ## Changes - Copies the changes made in navapbc/template-infra#352
- Loading branch information
Showing
3 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,10 @@ git clone --single-branch --branch main --depth 1 [email protected]:navapbc/templat | |
echo "Install template" | ||
./template-application-flask/template-only-bin/install-template.sh | ||
|
||
# Store template version in a file | ||
cd template-application-flask | ||
git rev-parse HEAD >../.template-flask-version | ||
cd - | ||
|
||
echo "Clean up template-application-flask folder" | ||
rm -fr template-application-flask |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,46 @@ | ||
#!/bin/bash | ||
# | ||
# ----------------------------------------------------------------------------- | ||
# This script updates template-application-flask in your project. Run | ||
# This script from your project's root directory. | ||
# | ||
# Positional parameters: | ||
# TARGET_VERSION (optional) – the version of template-application-flask to upgrade to. | ||
# Defaults to main. | ||
# ----------------------------------------------------------------------------- | ||
set -euo pipefail | ||
|
||
SCRIPT_DIR=$(dirname $0) | ||
TARGET_VERSION=${1:-"main"} | ||
|
||
CURRENT_VERSION=$(cat .template-flask-version) | ||
|
||
echo "Clone template-application-flask" | ||
git clone https://github.com/navapbc/template-application-flask.git | ||
|
||
echo "Creating patch" | ||
cd template-application-flask | ||
git checkout $TARGET_VERSION | ||
|
||
# Get version hash to update .template-flask-version after patch is successful | ||
TARGET_VERSION_HASH=$(git rev-parse HEAD) | ||
|
||
# Note: Keep this list in sync with the files copied in install-template.sh | ||
INCLUDE_PATHS=" \ | ||
github \ | ||
.dockleconfig \ | ||
.hadolint.yaml \ | ||
app \ | ||
docker-compose.yml \ | ||
docs" | ||
git diff $CURRENT_VERSION $TARGET_VERSION -- $INCLUDE_PATHS >patch | ||
cd - | ||
|
||
echo "Applying patch" | ||
# Note: Keep this list in sync with the removed files in install-template.sh | ||
EXCLUDE_OPT="--exclude=.github/workflows/template-only-*" | ||
git apply $EXCLUDE_OPT --allow-empty template-application-flask/patch | ||
|
||
echo "Saving new template version to .template-application-flask" | ||
echo $TARGET_VERSION_HASH >.template-flask-version | ||
|
||
echo "Install template" | ||
$SCRIPT_DIR/install-template.sh | ||
echo "Clean up template-application-flask folder" | ||
rm -fr template-application-flask |