Skip to content

Commit 102b1a0

Browse files
authored
fix: use github.head_ref env var as trusted input
1 parent a362e5f commit 102b1a0

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

action.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ runs:
2626
INPUT_SLUG_MAXLENGTH: ${{ inputs.slug-maxlength }}
2727
INPUT_SHORT_LENGTH: ${{ inputs.short-length }}
2828

29+
# From Environment Variables
2930
- uses: rlespinasse/slugify-value@v1.4.0
3031
with:
3132
key: GITHUB_REPOSITORY
@@ -48,30 +49,25 @@ runs:
4849
prefix: ${{ inputs.prefix }}
4950
slug-maxlength: ${{ inputs.slug-maxlength }}
5051

51-
# Specific values
52+
# From Specific values
5253
- uses: rlespinasse/slugify-value@v1.4.0
5354
with:
5455
key: GITHUB_EVENT_REF
5556
value: ${{ github.event.ref }}
5657
prefix: ${{ inputs.prefix }}
5758
slug-maxlength: ${{ inputs.slug-maxlength }}
58-
59-
# Calculated values
60-
- id: get-github-ref-name
61-
run: |
62-
refname="${{ github.head_ref || github.ref_name }}"
63-
if [ -f "$GITHUB_OUTPUT" ]; then
64-
echo "github-ref-name=${refname}" >> "$GITHUB_OUTPUT"
65-
else
66-
echo "::set-output name=github-ref-name::${refname}"
67-
fi
68-
shell: bash
6959
- uses: rlespinasse/slugify-value@v1.4.0
7060
with:
7161
key: GITHUB_REF_NAME
72-
value: ${{ steps.get-github-ref-name.outputs.github-ref-name }}
62+
# Related to https://github.com/rlespinasse/github-slug-action/issues/104
63+
value: ${{ env.GITHUB_HEAD_REF_RAW || env.GITHUB_REF_NAME_RAW }}
7364
prefix: ${{ inputs.prefix }}
7465
slug-maxlength: ${{ inputs.slug-maxlength }}
66+
env:
67+
GITHUB_HEAD_REF_RAW: ${{ github.head_ref }}
68+
GITHUB_REF_NAME_RAW: ${{ github.ref_name }}
69+
70+
# From Calculated values
7571
- id: get-github-repository-owner-part
7672
run: |
7773
ownerpart=$(echo $GITHUB_REPOSITORY | cut -d/ -f1)
@@ -103,7 +99,7 @@ runs:
10399
prefix: ${{ inputs.prefix }}
104100
slug-maxlength: ${{ inputs.slug-maxlength }}
105101

106-
# Short
102+
# From sha
107103
- uses: rlespinasse/shortify-git-revision@v1.6.0
108104
with:
109105
name: GITHUB_SHA

0 commit comments

Comments
 (0)