Skip to content

Commit e770dbe

Browse files
authored
Merge branch 'main' into DEVOPS-2522-lightrun-k-8-s-operator-helm-chart-update-readme
2 parents 52ef98c + 05b7f39 commit e770dbe

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

.github/workflows/init_container.yaml

+40-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ on:
1414
description: "Force build"
1515
required: false
1616
default: "false"
17+
is_internal:
18+
description: "Internal release"
19+
required: false
20+
default: "true"
1721

1822
jobs:
1923
set_image_tag_variable:
@@ -82,7 +86,37 @@ jobs:
8286
run: |
8387
python3 -m pip install semver
8488
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")
86120
if [[ $? -ne 0 ]] ; then
87121
echo "Failed to fetch existing tags"
88122
exit 1
@@ -98,12 +132,12 @@ jobs:
98132
echo "Comparing existing tag: $tag with new: ${{steps.set_tag.outputs.TAG_NAME}}"
99133
if [[ $(pysemver compare $tag ${{steps.set_tag.outputs.TAG_NAME}}) -ge 0 ]] ; then
100134
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"
102136
exit 0
103137
fi
104138
done
105139
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"
107141
108142
- name: Download agent artifacts
109143
run: |
@@ -125,7 +159,7 @@ jobs:
125159
uses: rtCamp/action-slack-notify@v2.2.0
126160
env:
127161
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 }}
131165
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

0 commit comments

Comments
 (0)