@@ -37,12 +37,18 @@ runs:
37
37
using : " composite"
38
38
steps :
39
39
- id : branch
40
+ env :
41
+ GITHUB_REF : ${{ github.ref }}
42
+ GITHUB_BASE_REF : ${{ github.event.pull_request.base.ref || github.base_ref }}
43
+ GITHUB_HEAD_REF : ${{ github.event.pull_request.head.ref || github.head_ref }}
44
+ GITHUB_EVENT_BASE_REF : ${{ github.event.base_ref }}
45
+ INPUTS_STRIP_TAG_PREFIX : ${{ inputs.strip_tag_prefix }}
40
46
run : |
41
47
# "Set branch names..."
42
- if [[ "${{ github.ref }} " != "refs/tags/"* ]]; then
43
- BASE_REF=$(printf "%q" "${{ github.event.pull_request.base.ref || github.base_ref }} ")
44
- HEAD_REF=$(printf "%q" "${{ github.event.pull_request.head.ref || github.head_ref }} ")
45
- REF=$(printf "%q" "${{ github.ref }} ")
48
+ if [[ "$GITHUB_REF " != "refs/tags/"* ]]; then
49
+ BASE_REF=$(printf "%q" "$GITHUB_BASE_REF ")
50
+ HEAD_REF=$(printf "%q" "$GITHUB_HEAD_REF ")
51
+ REF=$(printf "%q" "$GITHUB_REF ")
46
52
47
53
BASE_REF=${BASE_REF/refs\/heads\//}
48
54
HEAD_REF=${HEAD_REF/refs\/heads\//}
@@ -53,42 +59,55 @@ runs:
53
59
echo "head_ref_branch=$(eval printf "%s" "$HEAD_REF")" >> "$GITHUB_OUTPUT"
54
60
echo "ref_branch=$(eval printf "%s" "$REF_BRANCH")" >> "$GITHUB_OUTPUT"
55
61
else
56
- BASE_REF=$(printf "%q" "${{ github.event.base_ref }} ")
57
- BASE_REF=${BASE_REF/refs\/heads\/${{ inputs.strip_tag_prefix }} /}
62
+ BASE_REF=$(printf "%q" "$GITHUB_EVENT_BASE_REF ")
63
+ BASE_REF=${BASE_REF/refs\/heads\/$INPUTS_STRIP_TAG_PREFIX /}
58
64
59
65
echo "base_ref_branch=$(eval printf "%s" "$BASE_REF")" >> "$GITHUB_OUTPUT"
60
66
fi
61
67
shell : bash
62
68
- id : current_branch
69
+ env :
70
+ GITHUB_REF : ${{ github.ref }}
71
+ GITHUB_EVENT_NAME : ${{ github.event_name }}
72
+ HEAD_REF_BRANCH : ${{ steps.branch.outputs.head_ref_branch }}
73
+ REF_BRANCH : ${{ steps.branch.outputs.ref_branch }}
63
74
run : |
64
75
# "Set the current branch name..."
65
- if [[ "${{ github.ref }} " != "refs/tags/"* ]]; then
66
- if [[ ${{ github.event_name }} == *"pull_request"* ]]; then
67
- echo "current_branch=${{ steps.branch.outputs.head_ref_branch }} " >> "$GITHUB_OUTPUT"
76
+ if [[ "$GITHUB_REF " != "refs/tags/"* ]]; then
77
+ if [[ "$GITHUB_EVENT_NAME" == *"pull_request"* ]]; then
78
+ echo "current_branch=$HEAD_REF_BRANCH " >> "$GITHUB_OUTPUT"
68
79
else
69
- echo "current_branch=${{ steps.branch.outputs.ref_branch }} " >> "$GITHUB_OUTPUT"
80
+ echo "current_branch=$REF_BRANCH " >> "$GITHUB_OUTPUT"
70
81
fi
71
82
fi
72
83
shell : bash
73
84
- id : default
85
+ env :
86
+ GITHUB_REF : ${{ github.ref }}
87
+ CURRENT_BRANCH : ${{ steps.current_branch.outputs.current_branch }}
88
+ DEFAULT_BRANCH : ${{ github.event.repository.default_branch }}
89
+ FORK : ${{ github.event.pull_request.head.repo.fork }}
74
90
run : |
75
91
# "Set the default branch name..."
76
- if [[ "${{ github.ref }} " != "refs/tags/"* ]]; then
77
- if [[ "${{ steps.current_branch.outputs.current_branch }} " == "${{ github.event.repository.default_branch }} " && "${{ github.event.pull_request.head.repo.fork }} " != "true" ]]; then
92
+ if [[ "$GITHUB_REF " != "refs/tags/"* ]]; then
93
+ if [[ "$CURRENT_BRANCH " == "$DEFAULT_BRANCH " && "$FORK " != "true" ]]; then
78
94
echo "is_default=true" >> "$GITHUB_OUTPUT"
79
- echo "default_branch=${{ github.event.repository.default_branch }} " >> "$GITHUB_OUTPUT"
95
+ echo "default_branch=$DEFAULT_BRANCH " >> "$GITHUB_OUTPUT"
80
96
else
81
97
echo "is_default=false" >> "$GITHUB_OUTPUT"
82
- echo "default_branch=${{ github.event.repository.default_branch }} " >> "$GITHUB_OUTPUT"
98
+ echo "default_branch=$DEFAULT_BRANCH " >> "$GITHUB_OUTPUT"
83
99
fi
84
100
fi
85
101
shell : bash
86
102
- id : tag
103
+ env :
104
+ GITHUB_REF : ${{ github.ref }}
105
+ INPUTS_STRIP_TAG_PREFIX : ${{ inputs.strip_tag_prefix }}
87
106
run : |
88
107
# "Set the tag name..."
89
- if [[ "${{ github.ref }} " == "refs/tags/"* ]]; then
90
- REF=$(printf "%q" "${{ github.ref }} ")
91
- TAG=${REF/refs\/tags\/${{ inputs.strip_tag_prefix }}/}
108
+ if [[ "$GITHUB_REF " == "refs/tags/"* ]]; then
109
+ REF=$(printf "%q" "$GITHUB_REF ")
110
+ TAG=" ${REF/refs\/tags\/$INPUTS_STRIP_TAG_PREFIX/}"
92
111
93
112
echo "tag=$(eval printf "%s" "$TAG")" >> "$GITHUB_OUTPUT"
94
113
echo "is_tag=true" >> "$GITHUB_OUTPUT"
0 commit comments