From 6da0dac947e870e015290ea87349c41b0ef25058 Mon Sep 17 00:00:00 2001 From: chrisjsimpson Date: Sat, 28 Dec 2024 15:42:22 +0000 Subject: [PATCH] Fix #1426 ALLOWED_BRANCH_NAME_CHARS in auto issue branch creation --- .github/workflows/git-auto-issue-branch-creation.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/git-auto-issue-branch-creation.yml b/.github/workflows/git-auto-issue-branch-creation.yml index 133966d1..2b391648 100644 --- a/.github/workflows/git-auto-issue-branch-creation.yml +++ b/.github/workflows/git-auto-issue-branch-creation.yml @@ -28,13 +28,19 @@ jobs: tr -cd '[:alnum:]- ' | \ # Convert spaces to hyphens '-' tr ' ' '-' | \ - # Remove double hyphens - sed 's/--/-/' | \ # Ensure lowercase branch name tr '[:upper:]' '[:lower:]' | \ # Limit branch name to 60 characters cut -c -60` >> $GITHUB_ENV + ALLOWED_BRANCH_NAME_CHARS='[^a-zA-Z0-9-]' + # Loop through each character in the branch name, replacing any not allowed characer with a hyphen '-' + while [[ $ISSUE_BRANCH_NAME =~ $ALLOWED_BRANCH_NAME_CHARS ]]; do + ISSUE_BRANCH_NAME=`echo $ISSUE_BRANCH_NAME | sed -r "s/($ALLOWED_BRANCH_NAME_CHARS)/-/g" | sed 's/--/-/'` + done + + echo $ISSUE_BRANCH_NAME >> $GITHUB_ENV + - name: Create new branch run: | echo "The issue branch name is ${{ env.ISSUE_BRANCH_NAME}} "