Skip to content

Commit

Permalink
Merge pull request #6939 from TerriaJS/FIX-ci-on-capitals-11111111-an…
Browse files Browse the repository at this point in the history
…d-long-branch-names

Fix truncating branch name on CI not working
  • Loading branch information
steve9164 authored Oct 17, 2023
2 parents 0c8cc07 + c5fd9b7 commit 045e7b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions buildprocess/ci-cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ function makeSafeName(name) {
return name
.toLowerCase()
.replace(/[^-a-z0-9]/g, "-")
.substring(0, 40);
.substring(0, 32)
.replace(/-*$/, "");
}

function createIngress(branches) {
Expand All @@ -73,7 +74,7 @@ function createIngress(branches) {
host: "ci.terria.io",
http: {
paths: branches.map((branch) => ({
path: "/" + branch.name + "(/|$)(.*)",
path: "/" + makeSafeName(branch.name) + "(/|$)(.*)",
pathType: "ImplementationSpecific",
backend: {
service: {
Expand Down
4 changes: 3 additions & 1 deletion buildprocess/ci-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ if [[ $GITHUB_BRANCH =~ ^greenkeeper/ ]]; then
fi

# A version of the branch name that can be used as a DNS name once we prepend and append some stuff.
SAFE_BRANCH_NAME=$(printf '%s' "${GITHUB_BRANCH,,:0:40}" | sed 's/[^-a-z0-9]/-/g')
SAFE_BRANCH_NAME=$(printf '%s' "${GITHUB_BRANCH:0:32}" | sed -e 's/./\L&/g' -e 's/[^-a-z0-9]/-/g' -e 's/-*$//')

[[ $SAFE_BRANCH_NAME != $GITHUB_BRANCH ]] && echo "::warning file=buildprocess/ci-deploy.sh::Branch name sanitised to '${SAFE_BRANCH_NAME}' for kubernetes resources. This may work, however using branch names less than 32 characters long with [a-z0-9] and hyphen separators are preferred"

gh api /repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA} -f state=pending -f context=deployment -f target_url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}

Expand Down

0 comments on commit 045e7b4

Please sign in to comment.