Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions template-only-bin/download-and-install-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ git clone --single-branch --branch main --depth 1 git@github.com: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
6 changes: 4 additions & 2 deletions template-only-bin/install-template.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/bin/bash
#
# This script installs template-application-flask to your project. Run
# This script installs the template-application-flask to your project. Run
# This script from your project's root directory.
set -euo pipefail
set -euox pipefail

CUR_DIR=$(pwd)
SCRIPT_DIR=$(dirname $0)
TEMPLATE_DIR="$SCRIPT_DIR/.."

echo "Copy files from template-application-flask"
cd $TEMPLATE_DIR
# Note: Keep this list of paths in sync with INCLUDE_PATHS in update-template.sh
cp -r \
.github \
.dockleconfig \
Expand All @@ -21,4 +22,5 @@ cp -r \
cd -

echo "Remove files relevant only to template development"
# Note: Keep this list of paths in sync with EXCLUDE_OPT in update-template.sh
rm .github/workflows/template-only-*
44 changes: 40 additions & 4 deletions template-only-bin/update-template.sh
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