Skip to content

Commit ee2dd44

Browse files
authored
refactor(ci): improve harbor registry deployment and manifest pushing… (#329)
… logic Remove redundant tagging in image build step and move harbor pushing to a best-effort step. Add explicit login for harbor registry in both deploy and manifest actions. This simplifies image tagging during the build and ensures manifest pushing to harbor is non-blocking.
1 parent 9c9fb23 commit ee2dd44

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

.github/actions/deploy/action.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ runs:
126126
password: ${{ inputs.DOCKER_PASSWORD }}
127127
- name: Login to harbor registry
128128
if: ${{ inputs.harbor_registry != '' }}
129+
id: harbor_login
130+
continue-on-error: true
129131
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
130132
with:
131133
registry: ${{ inputs.harbor_registry }}
@@ -180,14 +182,9 @@ runs:
180182
with:
181183
context: ./source
182184
file: ${{ inputs.target_dockerfile }}
183-
# two tags;
184-
# - $target_tag
185-
# - $target_tag-commit
186185
tags: |
187186
${{ inputs.target_repository }}:${{ inputs.target_tag }}-${{ steps.git_commit_hash.outputs.git_commit_hash }}
188187
${{ inputs.target_repository }}:${{ inputs.target_tag }}
189-
${{ inputs.harbor_registry != '' && format('{0}/{1}:{2}-{3}', inputs.harbor_registry, inputs.target_repository, inputs.target_tag, steps.git_commit_hash.outputs.git_commit_hash) || '' }}
190-
${{ inputs.harbor_registry != '' && format('{0}/{1}:{2}', inputs.harbor_registry, inputs.target_repository, inputs.target_tag) || '' }}
191188
push: true
192189
platforms: ${{ inputs.platform }}
193190
build-args: |
@@ -199,6 +196,16 @@ runs:
199196
commit=${{ steps.git_commit_hash.outputs.git_commit_hash }}
200197
version=${{ inputs.source_ref }}
201198
buildnum=${{ github.run_number }}
199+
- name: Push to harbor registry (best-effort)
200+
if: ${{ inputs.build_script == '' && inputs.harbor_registry != '' && steps.harbor_login.outcome == 'success' }}
201+
continue-on-error: true
202+
shell: bash
203+
run: |
204+
echo "Pushing to harbor registry (best-effort)..."
205+
docker buildx imagetools create \
206+
--tag ${{ inputs.harbor_registry }}/${{ inputs.target_repository }}:${{ inputs.target_tag }}-${{ steps.git_commit_hash.outputs.git_commit_hash }} \
207+
--tag ${{ inputs.harbor_registry }}/${{ inputs.target_repository }}:${{ inputs.target_tag }} \
208+
${{ inputs.target_repository }}:${{ inputs.target_tag }}-${{ steps.git_commit_hash.outputs.git_commit_hash }} || echo "Harbor push failed, continuing..."
202209
- name: Image digest & tags
203210
shell: bash
204211
if: ${{ inputs.build_script == '' }}

.github/actions/manifest/action.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,28 @@ runs:
9898
with:
9999
username: ${{ inputs.DOCKER_USERNAME }}
100100
password: ${{ inputs.DOCKER_PASSWORD }}
101+
- name: Login to harbor registry
102+
if: ${{ inputs.harbor_registry != '' }}
103+
id: harbor_login
104+
continue-on-error: true
105+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
106+
with:
107+
registry: ${{ inputs.harbor_registry }}
108+
username: ${{ inputs.HARBOR_USERNAME }}
109+
password: ${{ inputs.HARBOR_PASSWORD }}
101110

102111
- name: Create and push manifest images to dockerhub
103112
shell: bash
104113
run: |
105114
docker buildx imagetools create --dry-run -t ${{ inputs.target_repository }}:${{ inputs.target_tag }} -t ${{ inputs.target_repository }}:${{ inputs.target_tag }}-${{ inputs.git_commit_hash }} ${{ steps.generate_images_list.outputs.images }}
106115
docker buildx imagetools create -t ${{ inputs.target_repository }}:${{ inputs.target_tag }} -t ${{ inputs.target_repository }}:${{ inputs.target_tag }}-${{ inputs.git_commit_hash }} ${{ steps.generate_images_list.outputs.images }}
116+
- name: Create and push manifest images to harbor (best-effort)
117+
if: ${{ inputs.harbor_registry != '' && steps.harbor_login.outcome == 'success' }}
118+
continue-on-error: true
119+
shell: bash
120+
run: |
121+
echo "Pushing manifest to harbor registry (best-effort)..."
122+
docker buildx imagetools create \
123+
-t ${{ inputs.harbor_registry }}/${{ inputs.target_repository }}:${{ inputs.target_tag }} \
124+
-t ${{ inputs.harbor_registry }}/${{ inputs.target_repository }}:${{ inputs.target_tag }}-${{ inputs.git_commit_hash }} \
125+
${{ steps.generate_images_list.outputs.images }} || echo "Harbor manifest push failed, continuing..."

0 commit comments

Comments
 (0)