mirror of
https://github.com/goharbor/harbor
synced 2025-04-18 21:30:32 +00:00
Fixes Publish to Github Packages (#18180)
1. Creates a publishPackages function in tools/release/release_utils.sh 2. Uses the publishPackages function in publish_release workflow Fixes issue 18138 Signed-off-by: Nagesh Bansal <nageshbansal59@gmail.com> Co-authored-by: Wang Yan <wangyan@vmware.com>
This commit is contained in:
parent
9b61d34c4c
commit
125daf9cdb
5
.github/workflows/publish_release.yml
vendored
5
.github/workflows/publish_release.yml
vendored
|
@ -58,7 +58,10 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
tar -zxf ${{ env.OFFLINE_PACKAGE_PATH }}
|
tar -zxf ${{ env.OFFLINE_PACKAGE_PATH }}
|
||||||
docker load -i ./harbor/harbor.${{ env.BASE_TAG }}.tar.gz
|
docker load -i ./harbor/harbor.${{ env.BASE_TAG }}.tar.gz
|
||||||
source tools/release/release_utils.sh && publishImages ${{ env.CUR_TAG }} ${{ env.BASE_TAG }} ${{ secrets.DOCKER_HUB_USERNAME }} ${{ secrets.DOCKER_HUB_PASSWORD }}
|
images="$(docker images --format "{{.Repository}}" --filter=reference='goharbor/*:${{ env.BASE_TAG }}' | xargs)"
|
||||||
|
source tools/release/release_utils.sh
|
||||||
|
publishImages ${{ env.CUR_TAG }} ${{ env.BASE_TAG }} ${{ secrets.DOCKER_HUB_USERNAME }} ${{ secrets.DOCKER_HUB_PASSWORD }} $images
|
||||||
|
publishPackages ${{ env.CUR_TAG }} ${{ env.BASE_TAG }} ${{ github.actor }} ${{ secrets.GITHUB_TOKEN }} $images
|
||||||
- name: Generate release notes
|
- name: Generate release notes
|
||||||
run: |
|
run: |
|
||||||
release_notes_path=$(pwd)/release-notes.txt
|
release_notes_path=$(pwd)/release-notes.txt
|
||||||
|
|
|
@ -59,8 +59,8 @@ function publishImages {
|
||||||
local baseTag=$2
|
local baseTag=$2
|
||||||
local dockerHubUser=$3
|
local dockerHubUser=$3
|
||||||
local dockerHubPassword=$4
|
local dockerHubPassword=$4
|
||||||
|
local images=${@:5}
|
||||||
docker login -u $dockerHubUser -p $dockerHubPassword
|
docker login -u $dockerHubUser -p $dockerHubPassword
|
||||||
local images="$(docker images --format "{{.Repository}}" --filter=reference='goharbor/*:'$baseTag'')"
|
|
||||||
for image in $images
|
for image in $images
|
||||||
do
|
do
|
||||||
echo "push image: $image"
|
echo "push image: $image"
|
||||||
|
@ -70,6 +70,22 @@ function publishImages {
|
||||||
docker logout
|
docker logout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function publishPackages {
|
||||||
|
local curTag=$1
|
||||||
|
local baseTag=$2
|
||||||
|
local ghcrUser=$3
|
||||||
|
local ghcrPassword=$4
|
||||||
|
local images=${@:5}
|
||||||
|
docker login ghcr.io -u $ghcrUser -p $ghcrPassword
|
||||||
|
for image in $images
|
||||||
|
do
|
||||||
|
echo "push image: $image"
|
||||||
|
docker tag $image:$baseTag "ghcr.io/"$image:$curTag
|
||||||
|
retry 5 docker push "ghcr.io/"$image:$curTag
|
||||||
|
done
|
||||||
|
docker logout ghcr.io
|
||||||
|
}
|
||||||
|
|
||||||
function retry {
|
function retry {
|
||||||
local -r -i max="$1"; shift
|
local -r -i max="$1"; shift
|
||||||
local -i n=1
|
local -i n=1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user