generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yaml
More file actions
18 lines (18 loc) · 748 Bytes
/
action.yaml
File metadata and controls
18 lines (18 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
name: "Normalize branch name"
description: "Normalize branch name"
outputs:
normalized_branch_name:
description: 14 character branch identifier (0000-thebranch)
value: ${{ steps.normalize_branch_name.outputs.normalized_branch_name }}
runs:
using: "composite"
steps:
- id: normalize_branch_name
shell: bash
run: |
branch=$(git rev-parse --abbrev-ref HEAD)
stripped=$(echo $branch | sed -e 's/[^a-zA-Z0-9-]//g' | tr '[:upper:]' '[:lower:]')
starting_from_jira_ref=$(echo $stripped | sed -n 's/.*\([0-9]\{4,\}.*\)/\1/p')
with_fallback=${starting_from_jira_ref:-$stripped}
chopped=$(echo $with_fallback | head -c 14)
echo "normalized_branch_name=$chopped" >> $GITHUB_OUTPUT