Skip to content
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

DIA-3614: Replace Artifactory with Harbor #92

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ inputs:
docker-registry:
description: 'Docker Registry'
required: true
default: 'staffbase.jfrog.io'
default: 'registry.staffbase.com'
docker-registry-api:
description: 'Docker Registry API'
required: false
default: 'https://staffbase.jfrog.io/artifactory/api/docker/'
default: 'https://registry.staffbase.com/v2/'
docker-image:
description: 'Docker Image'
required: true
Expand Down Expand Up @@ -175,17 +175,13 @@ runs:
CHECK_EXISTING_TAGS="master-${GITHUB_SHA::8} main-${GITHUB_SHA::8}"
CONTENT_TYPE="application/vnd.docker.distribution.manifest.v2+json"

# split docker-image on / into repository and image
REPO=$(echo ${{ inputs.docker-image}} | cut -d'/' -f1)
IMAGE=$(echo ${{ inputs.docker-image}} | cut -d'/' -f2)

echo "CHECK_EXISTING_TAGS: ${CHECK_EXISTING_TAGS}"
echo "RELEASE_TAG: ${RELEASE_TAG:1}"
echo "Check if an image already exists for ${{ inputs.docker-image }}:main|master-${GITHUB_SHA::8} 🐋 ⬇"

MANIFEST=""
for tag in $CHECK_EXISTING_TAGS; do
MANIFEST=$(curl -H "Accept: ${CONTENT_TYPE}" -u "${{ inputs.docker-username }}:${{ inputs.docker-password }}" "${{ inputs.docker-registry-api }}${REPO}/v2/{$IMAGE}/manifests/${tag}")
MANIFEST=$(curl -H "Accept: ${CONTENT_TYPE}" -u '${{ inputs.docker-username }}:${{ inputs.docker-password }}' "${{ inputs.docker-registry-api }}${{ inputs.docker-image}}/manifests/${tag}")

if [[ $MANIFEST == *"errors"* ]]; then
echo "No image found for ${{ inputs.docker-image }}:${tag} 🚫"
Expand All @@ -199,8 +195,8 @@ runs:
done

echo "Retagging image with release version and :latest tags for ${{ inputs.docker-image }} 🏷"
curl --fail-with-body -X PUT -H "Content-Type: ${CONTENT_TYPE}" -u "${{ inputs.docker-username }}:${{ inputs.docker-password }}" -d "${MANIFEST}" "${{ inputs.docker-registry-api }}${REPO}/v2/{$IMAGE}/manifests/${{ steps.preparation.outputs.tag }}"
curl --fail-with-body -X PUT -H "Content-Type: ${CONTENT_TYPE}" -u "${{ inputs.docker-username }}:${{ inputs.docker-password }}" -d "${MANIFEST}" "${{ inputs.docker-registry-api }}${REPO}/v2/{$IMAGE}/manifests/${{ steps.preparation.outputs.latest }}"
curl --fail-with-body -X PUT -H "Content-Type: ${CONTENT_TYPE}" -u '${{ inputs.docker-username }}:${{ inputs.docker-password }}' -d "${MANIFEST}" "${{ inputs.docker-registry-api }}${{ inputs.docker-image}}/manifests/${{ steps.preparation.outputs.tag }}"
curl --fail-with-body -X PUT -H "Content-Type: ${CONTENT_TYPE}" -u '${{ inputs.docker-username }}:${{ inputs.docker-password }}' -d "${MANIFEST}" "${{ inputs.docker-registry-api }}${{ inputs.docker-image}}/manifests/${{ steps.preparation.outputs.latest }}"

- name: Checkout GitOps Repository
if: inputs.gitops-token != ''
Expand Down
Loading