-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
69 lines (60 loc) · 2.27 KB
/
action.yml
File metadata and controls
69 lines (60 loc) · 2.27 KB
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
name: "Create the default Container Tags for the GlueOps Platform"
author: "@GlueOps"
description: "The GlueOps Platform orchestrates CI/CD using container tags. This action produces the tags used by the platform"
branding:
icon: 'tag'
color: 'yellow'
outputs:
tags_csv:
description: 'Comma-separated list of GlueOps image tags'
value: ${{ steps.create-tags.outputs.tags }}
clean_target_ref:
description: 'Target reference with invalid tag characters removed'
value: ${{ steps.create-tags.outputs.target-ref}}
target_ref_type:
description: 'Type of Target ref, as ["branch", "pull_request", "tag", "unknown"]'
value: ${{ steps.create-tags.outputs.target-ref-type }}
runs:
using: "composite"
steps:
- name: Create Tags
id: create-tags
shell: bash
run: |
echo "::group::determine ref"
if [[ $GITHUB_REF == refs/heads/* ]]; then
REF_TYPE=branch
TARGET_REF=${GITHUB_REF#refs/heads/}
elif [[ $GITHUB_REF == refs/tags/* ]] || [[ -n "${{ github.event.release.tag_name }}" ]]; then
REF_TYPE=tag
TARGET_REF=${{ github.event.release.tag_name }}
if [ -z "$TARGET_REF" ]; then
TARGET_REF=${GITHUB_REF#refs/tags/}
fi
elif [[ $GITHUB_REF == refs/pull/* ]]; then
REF_TYPE=pull_request
TARGET_REF=$GITHUB_SHA
else
REF_TYPE=unknown
fi
echo "target-ref-type=$TARGET_REF" >> $GITHUB_OUTPUT
echo "::endgroup::"
# Create default tags
SHA="${{ github.sha }}"
SHORT_SHA="${SHA:0:7}"
# Remove invalid tag characters from TARGET_REF
TARGET_REF=${TARGET_REF////-} # Replace slashes with hyphens
TARGET_REF=${TARGET_REF//[^a-zA-Z0-9_.-]/_} # Replace invalid characters with underscores
TARGET_REF=${TARGET_REF// /_} # Replace whitespaces with underscores
TARGET_REF=${TARGET_REF,,} # Convert to lowercase
echo "target-ref=$TARGET_REF" >> $GITHUB_OUTPUT
# Array of tags to generate
TAGS_ARRAY=(
"${TARGET_REF}"
"${SHORT_SHA}"
"${SHA}"
)
IFS=','
TAGS=${TAGS_ARRAY[*]}
echo "Computed tags: $TAGS"
echo "tags=$TAGS" >> $GITHUB_OUTPUT