|
12 | 12 | # |
13 | 13 | # Run the script - |
14 | 14 | # |
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'. |
16 | 21 | # |
17 | 22 |
|
18 | 23 | set -e |
19 | 24 |
|
| 25 | +deploy_tag="${1:-develop}" |
| 26 | + |
20 | 27 | base_folder=$HOME/github-automation |
21 | 28 | github_organization="boostorg" |
22 | 29 | 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" |
23 | 31 |
|
24 | 32 | mkdir -p ${base_folder}/${github_organization} |
25 | 33 | cd ${base_folder}/${github_organization} |
@@ -87,8 +95,34 @@ for repo in ${list_of_repos}; do |
87 | 95 | exit 1 |
88 | 96 | fi |
89 | 97 |
|
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}" |
92 | 126 |
|
93 | 127 | echo "Running 'git push' from the master branch" |
94 | 128 | git push |
|
0 commit comments