@@ -10,6 +10,10 @@ inputs:
1010 description : ' The prefix that should be stripped from the branch e.g `release/` -> with a branch `release/1.0` -> returns `1.0`'
1111 default : ' '
1212 required : false
13+ replace_slashes_with_hyphens :
14+ description : ' Replace forward slashes with hyphens in branch names'
15+ default : ' false'
16+ required : false
1317
1418outputs :
1519 is_default :
4852 GITHUB_EVENT_BASE_REF : ${{ github.event.base_ref }}
4953 INPUTS_STRIP_TAG_PREFIX : ${{ inputs.strip_tag_prefix }}
5054 INPUTS_STRIP_BRANCH_PREFIX : ${{ inputs.strip_branch_prefix }}
55+ INPUTS_REPLACE_SLASHES : ${{ inputs.replace_slashes_with_hyphens }}
5156 run : |
5257 # "Set branch names..."
5358 if [[ "$GITHUB_REF" != "refs/tags/"* ]]; then
@@ -64,13 +69,25 @@ runs:
6469 REF_BRANCH=${REF_BRANCH/$INPUTS_STRIP_BRANCH_PREFIX/}
6570 HEAD_REF=${HEAD_REF/$INPUTS_STRIP_BRANCH_PREFIX/}
6671
72+ # Replace slashes with hyphens if enabled
73+ if [[ "$INPUTS_REPLACE_SLASHES" == "true" ]]; then
74+ BASE_REF=${BASE_REF//\//-}
75+ HEAD_REF=${HEAD_REF//\//-}
76+ REF_BRANCH=${REF_BRANCH//\//-}
77+ fi
78+
6779 echo "base_ref_branch=$(eval printf "%s" "$BASE_REF")" >> "$GITHUB_OUTPUT"
6880 echo "head_ref_branch=$(eval printf "%s" "$HEAD_REF")" >> "$GITHUB_OUTPUT"
6981 echo "ref_branch=$(eval printf "%s" "$REF_BRANCH")" >> "$GITHUB_OUTPUT"
7082 else
7183 BASE_REF=$(printf "%q" "$GITHUB_EVENT_BASE_REF")
7284 BASE_REF=${BASE_REF/refs\/heads\/$INPUTS_STRIP_TAG_PREFIX/}
7385
86+ # Replace slashes with hyphens if enabled
87+ if [[ "$INPUTS_REPLACE_SLASHES" == "true" ]]; then
88+ BASE_REF=${BASE_REF//\//-}
89+ fi
90+
7491 echo "base_ref_branch=$(eval printf "%s" "$BASE_REF")" >> "$GITHUB_OUTPUT"
7592 fi
7693 shell : bash
@@ -112,12 +129,18 @@ runs:
112129 env :
113130 GITHUB_REF : ${{ github.ref }}
114131 INPUTS_STRIP_TAG_PREFIX : ${{ inputs.strip_tag_prefix }}
132+ INPUTS_REPLACE_SLASHES : ${{ inputs.replace_slashes_with_hyphens }}
115133 run : |
116134 # "Set the tag name..."
117135 if [[ "$GITHUB_REF" == "refs/tags/"* ]]; then
118136 REF=$(printf "%q" "$GITHUB_REF")
119137 TAG="${REF/refs\/tags\/$INPUTS_STRIP_TAG_PREFIX/}"
120138
139+ # Replace slashes with hyphens if enabled
140+ if [[ "$INPUTS_REPLACE_SLASHES" == "true" ]]; then
141+ TAG=${TAG//\//-}
142+ fi
143+
121144 echo "tag=$(eval printf "%s" "$TAG")" >> "$GITHUB_OUTPUT"
122145 echo "is_tag=true" >> "$GITHUB_OUTPUT"
123146 else
0 commit comments