14
14
description : " Force build"
15
15
required : false
16
16
default : " false"
17
+ is_internal :
18
+ description : " Internal release"
19
+ required : false
20
+ default : " true"
17
21
18
22
jobs :
19
23
set_image_tag_variable :
82
86
run : |
83
87
python3 -m pip install semver
84
88
existing_tags=()
85
- dockerhub_tags=$(curl -s "https://hub.docker.com/v2/namespaces/lightruncom/repositories/k8s-operator-init-java-agent-${{ matrix.agents.name }}/tags?page_size=50" | jq -r ".results[].name")
89
+
90
+ # Set repository suffix based on is_internal input
91
+ repo_suffix=""
92
+ if [[ "${{ inputs.is_internal }}" == "true" ]] ; then
93
+ repo_suffix="-internal"
94
+ fi
95
+
96
+
97
+ # Get Docker Hub JWT token
98
+ TOKEN=$(curl -s -H "Content-Type: application/json" \
99
+ -X POST -d '{"username": "${{ secrets.DOCKERHUB_USER }}", "password": "${{ secrets.DOCKERHUB_PASS }}"}' \
100
+ "https://hub.docker.com/v2/users/login/" | jq -r .token)
101
+
102
+ if [[ -z "$TOKEN" ]] ; then
103
+ echo "Failed to get Docker Hub authentication token"
104
+ exit 1
105
+ fi
106
+
107
+ # Define the base repository name
108
+ DOCKER_REPO="lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.name }}${repo_suffix}"
109
+
110
+ # Check if repository exists
111
+ repo_check=$(curl -s -f -H "Authorization: Bearer ${TOKEN}" \
112
+ "https://hub.docker.com/v2/namespaces/lightruncom/repositories/k8s-operator-init-java-agent-${{ matrix.agents.name }}${repo_suffix}")
113
+ if [[ $? -ne 0 ]] ; then
114
+ echo "Error: Repository ${DOCKER_REPO} does not exist in Docker Hub. Please create it first."
115
+ exit 1
116
+ fi
117
+
118
+ dockerhub_tags=$(curl -s -H "Authorization: Bearer ${TOKEN}" \
119
+ "https://hub.docker.com/v2/namespaces/lightruncom/repositories/k8s-operator-init-java-agent-${{ matrix.agents.name }}${repo_suffix}/tags?page_size=50" | jq -r ".results[].name")
86
120
if [[ $? -ne 0 ]] ; then
87
121
echo "Failed to fetch existing tags"
88
122
exit 1
@@ -98,12 +132,12 @@ jobs:
98
132
echo "Comparing existing tag: $tag with new: ${{steps.set_tag.outputs.TAG_NAME}}"
99
133
if [[ $(pysemver compare $tag ${{steps.set_tag.outputs.TAG_NAME}}) -ge 0 ]] ; then
100
134
echo "Existing tag: $tag is greater or equal than new: ${{ inputs.release_tag }}. Skip adding latest tag"
101
- echo "DOCKER_TAGS=lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.name } }:${{steps.set_tag.outputs.TAG_NAME}}" >> "$GITHUB_OUTPUT"
135
+ echo "DOCKER_TAGS=${DOCKER_REPO }:${{steps.set_tag.outputs.TAG_NAME}}" >> "$GITHUB_OUTPUT"
102
136
exit 0
103
137
fi
104
138
done
105
139
echo "Adding latest tag to ${{steps.set_tag.outputs.TAG_NAME}}"
106
- echo "DOCKER_TAGS=lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.name }} :${{steps.set_tag.outputs.TAG_NAME}},lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.name } }:latest" >> "$GITHUB_OUTPUT"
140
+ echo "DOCKER_TAGS=${DOCKER_REPO} :${{steps.set_tag.outputs.TAG_NAME}},${DOCKER_REPO }:latest" >> "$GITHUB_OUTPUT"
107
141
108
142
- name : Download agent artifacts
109
143
run : |
@@ -125,7 +159,7 @@ jobs:
125
159
uses : rtCamp/action-slack-notify@v2.2.0
126
160
env :
127
161
SLACK_CHANNEL : devops-alerts
128
- SLACK_COLOR : ${{ job.status }} # or a specific color like 'good' or '#ff00ff'
129
- SLACK_MESSAGE : " Tag ${{ inputs.release_tag }} | Platform ${{ matrix.agents.name }}"
130
- SLACK_TITLE : Init contianer build status - ${{ job.status }}
162
+ SLACK_COLOR : ${{ job.status }}
163
+ SLACK_MESSAGE : " Tag ${{ inputs.release_tag }} ${{ inputs.is_internal == 'true' && '(Internal)' || '' }} | Platform ${{ matrix.agents.name }}"
164
+ SLACK_TITLE : Init container ${{ inputs.is_internal == 'true' && '(Internal)' || '' }} build status - ${{ job.status }}
131
165
SLACK_WEBHOOK : ${{ secrets.SLACK_WEBHOOK }}
0 commit comments