@@ -10,10 +10,6 @@ inputs:
10
10
description : " Personal Access Token (PAT) used to authenticate with the GitHub Container Registry."
11
11
required : true
12
12
default : ${{ github.token }}
13
-
14
- your_pat :
15
- description : " Personal Access Token (PAT) used to authenticate with GitHub and the GitHub Container Registry."
16
- required : true
17
13
18
14
image_name :
19
15
description : ' Docker image is named after repository'
60
56
export BRANCH_NAME="${GITHUB_REF#refs/heads/}"
61
57
export BRANCH_NAME="${BRANCH_NAME#refs/tags/}"
62
58
echo "Current branch is: $BRANCH_NAME"
63
-
64
- # git clone --depth 1 --branch $BRANCH_NAME https://${{ inputs.your_pat }}@github.com/owner/repo .
65
- git clone --depth=1 --branch="$BRANCH_NAME" "https://${DOCKER_IO_USER}:${{ inputs.your_pat }}@github.com/${{ github.repository }}" .
59
+
60
+ git clone --depth=1 --branch="$BRANCH_NAME" "https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}" .
66
61
echo "Using $(docker -v)"
67
62
echo "::endgroup::"
68
63
@@ -78,23 +73,39 @@ runs:
78
73
echo "::group::Set commit tags"
79
74
echo "Event payload: ${{ toJson(github.event_name) }}"
80
75
81
- if [ -z "${IMAGE_TAG}" ]; then
82
- BRANCH_NAME="${BRANCH_NAME#refs/tags/}"
83
- BRANCH_NAME="${BRANCH_NAME#refs/heads/}"
84
- BRANCH_NAME=${BRANCH_NAME////-} # Replace slashes with hyphens
85
- BRANCH_NAME=${BRANCH_NAME//[^a-zA-Z0-9_.-]/_} # Replace invalid characters with underscores
86
- BRANCH_NAME=${BRANCH_NAME// /_} # Replace whitespaces with underscores
87
- BRANCH_NAME=${BRANCH_NAME,,} # Convert to lowercase
88
-
89
- export COMMIT_TAG="$BRANCH_NAME"
90
- export SHA="${{ github.sha }}"
91
- export SHORT_SHA="${SHA:0:7}"
76
+ #for release events, the tag name is available as github.event.release.tag_name, long SHA as github.sha and short SHA as github.sha_short
77
+ # if [ "${{ github.event_name }}" = "release" ]; then
78
+ # export TAG_NAME="${{ github.event.release.tag_name }}"
79
+ # export COMMIT_TAG="${TAG_NAME#refs/tags/}"
80
+ # export SHA="${{ github.sha }}"
81
+ # export SHORT_SHA="${SHA:0:7}"
92
82
93
- echo "Branch Name ${COMMIT_TAG}"
94
- echo "Short SHA ${SHORT_SHA}"
95
- echo "Long SHA ${SHA}"
96
- fi
97
-
83
+ # echo "Release Version ${COMMIT_TAG}"
84
+ # echo "Short SHA ${SHORT_SHA}"
85
+ # echo "Long SHA ${SHA}"
86
+
87
+ # else
88
+ #for commits, the tag name is available as github.ref, long SHA as github.sha and short SHA as github.sha_short
89
+ if [ -z "${IMAGE_TAG}" ]; then
90
+ BRANCH_NAME="${BRANCH_NAME#refs/tags/}"
91
+ BRANCH_NAME="${BRANCH_NAME#refs/heads/}"
92
+
93
+
94
+ # BRANCH_NAME="${BRANCH_NAME#refs/heads/}" # Remove refs/heads/ prefix
95
+ BRANCH_NAME=${BRANCH_NAME////-} # Replace slashes with hyphens
96
+ BRANCH_NAME=${BRANCH_NAME//[^a-zA-Z0-9_.-]/_} # Replace invalid characters with underscores
97
+ BRANCH_NAME=${BRANCH_NAME// /_} # Replace whitespaces with underscores
98
+ BRANCH_NAME=${BRANCH_NAME,,} # Convert to lowercase
99
+ export COMMIT_TAG="$BRANCH_NAME"
100
+ export SHA="${{ github.sha }}"
101
+ export SHORT_SHA="${SHA:0:7}"
102
+
103
+ echo "Branch Name ${COMMIT_TAG}"
104
+ echo "Short SHA ${SHORT_SHA}"
105
+ echo "Long SHA ${SHA}"
106
+ fi
107
+ # fi
108
+
98
109
# convert the image name to lowercase
99
110
export IMAGE_NAME=$(echo "${IMAGE_NAME}" | tr '[:upper:]' '[:lower:]')
100
111
echo "::endgroup::"
0 commit comments