mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 02:05:41 +01:00
Publish images to Docker Hub (#5264)
This commit enables the images publishing to Docker Hub in Drone CI. Every pull request merging will trigger this process.
This commit is contained in:
parent
ad7a85da51
commit
fd5c17bced
@ -50,6 +50,8 @@ pipeline:
|
||||
- mail_pwd
|
||||
- npm_password
|
||||
- npm_username
|
||||
- docker_hub_username
|
||||
- docker_hub_password
|
||||
commands:
|
||||
- export DOMAIN=${CI_DOMAIN}
|
||||
- export HOST_CONTAINER_ID=$(hostname)
|
||||
|
@ -115,6 +115,18 @@ function package_offline_installer {
|
||||
du -ks $harbor_build_bundle | awk '{print $1 / 1024}' | { read x; echo $x MB; }
|
||||
}
|
||||
|
||||
# publish images to Docker Hub
|
||||
function publishImage {
|
||||
echo "Publishing images to Docker Hub..."
|
||||
echo "The images on the host:"
|
||||
docker images
|
||||
docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD
|
||||
# rename the images with tag "dev" and push to Docker Hub
|
||||
docker images | sed -n "s|\(vmware/[-._a-z0-9]*\)\s*\(.*$Harbor_Assets_Version\).*|docker tag \1:\2 \1:dev;docker push \1:dev|p" | bash
|
||||
echo "Images are published successfully"
|
||||
docker images
|
||||
}
|
||||
|
||||
## --------------------------------------------- Run Test Case ---------------------------------------------
|
||||
echo "--------------------------------------------------"
|
||||
echo "Running CI for $DRONE_BUILD_EVENT on $DRONE_BRANCH"
|
||||
@ -187,6 +199,7 @@ if [ $upload_build == true ] && [ $rc -eq 0 ]; then
|
||||
uploader $harbor_build_bundle $harbor_target_bucket
|
||||
uploader harbor-offline-installer-latest.tgz $harbor_target_bucket
|
||||
upload_bundle_success=true
|
||||
publishImage
|
||||
fi
|
||||
|
||||
## --------------------------------------------- Upload Harbor Latest Build File ----------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user