-
Notifications
You must be signed in to change notification settings - Fork 2
/
update-template
executable file
·39 lines (30 loc) · 1.41 KB
/
update-template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# -----------------------------------------------------------------------------
# This script updates template-infra in your project. Run
# this script from your project's root directory.
#
# Positional parameters:
# target_version (optional) – the version of template-infra to upgrade to.
# Defaults to main.
# -----------------------------------------------------------------------------
set -euo pipefail
target_version=${1:-"main"}
current_version=$(cat .template-version)
echo "Clone template-infra"
git clone https://github.com/navapbc/template-infra.git
echo "Creating patch"
cd template-infra
git checkout "${target_version}"
# Get version hash to update .template-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
git diff "${current_version}" "${target_version}" --binary -- .github bin docs infra e2e Makefile .dockleconfig .gitignore .grype.yml .hadolint.yaml .trivyignore .terraform-version > update.patch
cd -
echo "Applying patch"
# Note: Keep this list in sync with the removed files in install-template
exclude_opt="--exclude=.github/workflows/template-only-*"
git apply "${exclude_opt}" --allow-empty template-infra/update.patch
echo "Saving new template version to .template-infra"
echo "${target_version_hash}" > .template-version
echo "Clean up template-infra folder"
rm -fr template-infra