Skip to content

Commit c5382ca

Browse files
committed
deploy-website.sh: deploy tag
1 parent cc1019d commit c5382ca

1 file changed

Lines changed: 37 additions & 3 deletions

File tree

scripts/deploy-website.sh

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,22 @@
1212
#
1313
# Run the script -
1414
#
15-
# ./deploy-website.sh
15+
# ./deploy-website.sh # deploys 'develop' (default)
16+
# ./deploy-website.sh r123 # deploys tag 'r123' where available
17+
#
18+
# If a tag argument is provided, it will be used as the merge source for
19+
# repos where that tag exists. Repos that do not contain the tag will
20+
# fall back to 'develop'.
1621
#
1722

1823
set -e
1924

25+
deploy_tag="${1:-develop}"
26+
2027
base_folder=$HOME/github-automation
2128
github_organization="boostorg"
2229
list_of_repos="${github_organization}/boostlook ${github_organization}/website-v2-docs ${github_organization}/website-v2"
30+
list_of_repos_verify_tag="${github_organization}/website-v2"
2331

2432
mkdir -p ${base_folder}/${github_organization}
2533
cd ${base_folder}/${github_organization}
@@ -87,8 +95,34 @@ for repo in ${list_of_repos}; do
8795
exit 1
8896
fi
8997

90-
echo "Running 'git merge --ff-only develop'"
91-
git merge --ff-only develop
98+
# Determine the merge source: use the deploy tag if it exists in this repo,
99+
# otherwise fall back to 'develop'.
100+
merge_source="refs/heads/develop"
101+
if [ "${deploy_tag}" != "develop" ]; then
102+
if git rev-parse "${deploy_tag}" > /dev/null 2>&1 ; then
103+
merge_source="refs/tags/${deploy_tag}"
104+
echo "Tag '${deploy_tag}' found in this repo. Using it as the merge source."
105+
else
106+
if echo "${list_of_repos_verify_tag}" | grep -qw "${repo}"; then
107+
echo ""
108+
echo "WARNING: Tag '${deploy_tag}' not found in this repo. Falling back to 'develop'."
109+
echo ""
110+
echo "This is very likely a problem since you specified a tag, but we do not see it in the repo."
111+
echo ""
112+
read -r -p "Proceed? [yN] " response
113+
response="${response:-N}"
114+
if [[ ! "${response}" =~ ^[Yy]$ ]]; then
115+
echo "Not proceeding. Exiting."
116+
exit 1
117+
fi
118+
else
119+
echo "Tag '${deploy_tag}' not found in this repo. Falling back to 'develop'."
120+
fi
121+
fi
122+
fi
123+
124+
echo "Running 'git merge --ff-only ${merge_source}'"
125+
git merge --ff-only "${merge_source}"
92126

93127
echo "Running 'git push' from the master branch"
94128
git push

0 commit comments

Comments
 (0)