forked from rlespinasse/github-slug-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
115 lines (111 loc) · 4.01 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: "GitHub Slug Action"
description: "GitHub Action to expose slug value of environment variables inside your GitHub workflow"
author: "Romain Lespinasse"
branding:
icon: "minimize"
color: "blue"
inputs:
prefix:
description: "Value to prepend to each generated variable"
default: ""
required: false
slug-maxlength:
description: "Max length of the slugified values"
default: "63"
required: true
short-length:
description: "Length of the shortify values (git default if empty)"
required: false
runs:
using: "composite"
steps:
- run: $GITHUB_ACTION_PATH/preflight.sh
id: prefligth
shell: bash
env:
INPUT_SLUG_MAXLENGTH: ${{ inputs.slug-maxlength }}
INPUT_SHORT_LENGTH: ${{ inputs.short-length }}
# From Environment Variables
- uses: rlespinasse/[email protected]
with:
key: GITHUB_REPOSITORY
value: ${{ github.repository }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/[email protected]
with:
key: GITHUB_REF
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/[email protected]
with:
key: GITHUB_HEAD_REF
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/[email protected]
with:
key: GITHUB_BASE_REF
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
# From Specific values
- uses: rlespinasse/[email protected]
with:
key: GITHUB_EVENT_REF
value: ${{ github.event.ref }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/[email protected]
with:
key: GITHUB_REF_NAME
# Related to https://github.com/rlespinasse/github-slug-action/issues/104
value: ${{ env.GITHUB_HEAD_REF_RAW || env.GITHUB_REF_NAME_RAW }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
env:
GITHUB_HEAD_REF_RAW: ${{ github.head_ref }}
GITHUB_REF_NAME_RAW: ${{ github.ref_name }}
# From Calculated values
- id: get-github-repository-owner-part
run: |
ownerpart=$(echo $GITHUB_REPOSITORY | cut -d/ -f1)
if [ -f "$GITHUB_OUTPUT" ]; then
echo "github-repository-owner-part=${ownerpart}" >> "$GITHUB_OUTPUT"
else
echo "::set-output name=github-repository-owner-part::${ownerpart}"
fi
shell: bash
- uses: rlespinasse/[email protected]
with:
key: GITHUB_REPOSITORY_OWNER_PART
value: ${{ steps.get-github-repository-owner-part.outputs.github-repository-owner-part }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- id: get-github-repository-name-part
run: |
namepart=$(echo $GITHUB_REPOSITORY | cut -d/ -f2)
if [ -f "$GITHUB_OUTPUT" ]; then
echo "github-repository-name-part=${namepart}" >> "$GITHUB_OUTPUT"
else
echo "::set-output name=github-repository-name-part::${namepart}"
fi
shell: bash
- uses: rlespinasse/[email protected]
with:
key: GITHUB_REPOSITORY_NAME_PART
value: ${{ steps.get-github-repository-name-part.outputs.github-repository-name-part }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
# From sha
- uses: rlespinasse/[email protected]
with:
name: GITHUB_SHA
short-on-error: true
length: ${{ steps.prefligth.outputs.PREFLIGHT_SHORT_LENGTH }}
prefix: ${{ inputs.prefix }}
- uses: rlespinasse/[email protected]
with:
name: GITHUB_EVENT_PULL_REQUEST_HEAD_SHA
revision: ${{ github.event.pull_request.head.sha }}
short-on-error: true
length: ${{ steps.prefligth.outputs.PREFLIGHT_SHORT_LENGTH }}
prefix: ${{ inputs.prefix }}