Skip to content

Commit

Permalink
chore: secureli 140 dependabot branch validation (#141)
Browse files Browse the repository at this point in the history
fix dependabot branch names getting hung up in validation
  • Loading branch information
sbates authored Jun 16, 2023
1 parent 7770ef2 commit 8b2424e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/get-current-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ if [ -z "$branch" ]; then
branch="${GITHUB_REF_NAME}"
fi
# Format the branch from "feature/abc-123-my-branch" to "abc123"
branch=$(echo "$branch" | cut -d'/' -f2 | cut -d'-' -f1-2 | tr '[:upper:]' '[:lower:]' | sed 's/-//g ; s/_//g')
if [[ $branch =~ dependabot ]]; then
branch=dependabot
else
branch=$(echo "$branch" | cut -d'/' -f2 | cut -d'-' -f1-2 | tr '[:upper:]' '[:lower:]' | sed 's/-//g ; s/_//g')
fi

echo "Branch has been set to $branch" 1>&2
else
echo "Branch is already defined as $branch" 1>&2
fi

# Check if short name work
if [[ $branch == "main" || $branch =~ ^secureli[0-9][0-9][0-9]$ || $branch =~ ^dependabot ]]; then
if [[ $branch == "main" || $branch =~ ^secureli[0-9][0-9][0-9]$ || $branch =~ "dependabot" ]]; then
echo "The branch name is a valid pattern."
else
echo "error The branch name ${branch} does not meet naming requirements. It should look something like feature/secureli-123-mybranchname."
Expand Down

0 comments on commit 8b2424e

Please sign in to comment.