Skip to content

Devops 1050 latest tag for init container #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jun 20, 2023
22 changes: 19 additions & 3 deletions .github/workflows/init_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Set release tag
shell: bash
run: |
echo "::set-output name=TAG_NAME::$(echo ${{ inputs.release_tag }} | sed -E 's/^([0-9]*\.[0-9]*\.[0-9]*).*/\1/')-init.${{ inputs.init_image_tag }}"
echo "TAG_NAME=$(echo ${{ inputs.release_tag }} | sed -E 's/^([0-9]*\.[0-9]*\.[0-9]*).*/\1/')-init.${{ inputs.init_image_tag }}" >> "$GITHUB_OUTPUT"
id: set_tag

- uses: actions/checkout@v3
Expand All @@ -48,18 +48,34 @@ jobs:
aws-secret-access-key: ${{ secrets.RELEASE_ARTIFACTS_MANAGER_SECRET }}
aws-region: us-east-1

- name: Set docker image tags
id: set_docker_tags
run: |
python3 -m pip install semver
existing_tags=($(curl -s https://hub.docker.com/v2/namespaces/lightruncom/repositories/k8s-operator-init-java-agent-{{ matrix.agents.platform }}/tags\?page_size\=100 | jq -r '.results[].name'))
for tag in $existing_tags
do
if [[ $(pysemver compare $tag ${{steps.set_tag.outputs.TAG_NAME}}) -ge 0 ]] ; then
echo "Existing tag: $tag is greater or equal than new: ${{ inputs.release_tag }}. Stopping"
echo "DOCKER_TAGS=lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.platform }}:${{steps.set_tag.outputs.TAG_NAME}}" >> "$GITHUB_OUTPUT"
exit 0
fi
done
echo "Adding latest tag to ${{steps.set_tag.outputs.TAG_NAME}}"
echo "DOCKER_TAGS=lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.platform }}:${{steps.set_tag.outputs.TAG_NAME}},lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.platform }}:latest" >> "$GITHUB_OUTPUT"

- name: Download agent artifacts
run: |
aws s3 cp s3://${{ secrets.RELEASE_ARTIFACTS_BUCKET }}/artifacts/${{ inputs.release_tag }}/${{ matrix.agents.file }} ./lightrun-init-agent/


- name: Build and push ${{ matrix.agents.platform }} container
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
file: ./lightrun-init-agent/Dockerfile
push: true
tags: "lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.platform }}:${{steps.set_tag.outputs.TAG_NAME}}"
tags: ${{steps.set_docker_tags.outputs.DOCKER_TAGS}}
build-args: |
FILE=${{ matrix.agents.file }}

Expand Down