Skip to content

Commit

Permalink
chore: deploy with version like tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeut committed Jun 8, 2024
1 parent 99f15a7 commit 9665d5a
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
#!/bin/bash
tag="quay.io/pypa/${POLICY}_${PLATFORM}"
build_id=$(git show -s --format=%cd-%h --date=short ${COMMIT_SHA})

set -euo pipefail

export TZ=UTC0

TAG="quay.io/pypa/${POLICY}_${PLATFORM}"
COMMIT_ABBREV_SHA=$(git show -s --format=%h ${COMMIT_SHA})
COMMIT_DATE=$(git show -s --format=%cd --date=short ${COMMIT_SHA})
BUILD_ID=${COMMIT_DATE}-${COMMIT_ABBREV_SHA}
# Dependabot does not work with the BUILD_ID format
# Use a version like tag
if $(git rev-parse --is-shallow-repository); then
git fetch --shallow-since=${COMMIT_DATE}T00:00:00Z
fi
BUILD_NUMBER=$(git rev-list --since=${COMMIT_DATE}T00:00:00Z --count ${COMMIT_SHA})
BUILD_ID2=${COMMIT_DATE//-/.}.${BUILD_NUMBER}

docker login -u $QUAY_USERNAME -p $QUAY_PASSWORD quay.io
docker tag ${tag}:${COMMIT_SHA} ${tag}:${build_id}
docker tag ${tag}:${COMMIT_SHA} ${tag}:latest
docker push ${tag}:${build_id}
docker push ${tag}:latest
docker tag ${TAG}:${COMMIT_SHA} ${TAG}:${BUILD_ID}
docker tag ${TAG}:${COMMIT_SHA} ${TAG}:${BUILD_ID2}
docker tag ${TAG}:${COMMIT_SHA} ${TAG}:latest
docker push ${TAG}:${BUILD_ID}
docker push ${TAG}:${BUILD_ID2}
docker push ${TAG}:latest

0 comments on commit 9665d5a

Please sign in to comment.