Skip to content

Commit 1f76bb3

Browse files
authored
[feature] migrate docker images to ghcr (#2520)
* update custom action Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * define token as input Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * clean up meta job Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * change build-and-publish-imageg.yaml Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * remove secret from workflow call Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * remove docker credentials from publish* images Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * revert meta step changes Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * revert changes Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * update Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * add dockerhub as a job Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * revert secrets Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * revert docker secrets Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * revert docker secrets Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * consolidate/merge registeries Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * fix inputs Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> * revert docker path name Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com> --------- Signed-off-by: mahdikhashan <mahdikhashan1@gmail.com>
1 parent 4884253 commit 1f76bb3

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

.github/workflows/build-and-publish-images.yaml

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Reusable workflows for publishing Katib images.
2-
name: Build And Publish Images
2+
name: Build and Publish Images
33

44
on:
55
workflow_call:
@@ -21,31 +21,50 @@ on:
2121

2222
jobs:
2323
build-and-publish:
24-
name: Publish Image
24+
name: Build and Publish Images
2525
runs-on: ubuntu-22.04
26+
2627
steps:
2728
- name: Checkout
2829
uses: actions/checkout@v4
2930

30-
- name: Docker Login
31-
# Trigger workflow only for kubeflow/katib repository with specific branch (master, release-.*) or tag (v.*).
32-
if: >-
33-
github.repository == 'kubeflow/katib' &&
34-
(github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-') || startsWith(github.ref, 'refs/tags/v'))
31+
- name: Set Publish Condition
32+
id: publish-condition
33+
shell: bash
34+
run: |
35+
if [[ "${{ github.repository }}" == 'kubeflow/katib' && \
36+
( "${{ github.ref }}" == 'refs/heads/master' || \
37+
"${{ github.ref }}" =~ ^refs/heads/release- || \
38+
"${{ github.ref }}" =~ ^refs/tags/v ) ]]; then
39+
echo "should_publish=true" >> $GITHUB_OUTPUT
40+
else
41+
echo "should_publish=false" >> $GITHUB_OUTPUT
42+
fi
43+
44+
- name: GHCR Login
45+
if: steps.publish-condition.outputs.should_publish == 'true'
46+
uses: docker/login-action@v3
47+
with:
48+
registry: ghcr.io
49+
username: ${{ github.actor }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: DockerHub Login
53+
if: steps.publish-condition.outputs.should_publish == 'true'
3554
uses: docker/login-action@v3
3655
with:
56+
registry: docker.io
3757
username: ${{ secrets.DOCKERHUB_USERNAME }}
3858
password: ${{ secrets.DOCKERHUB_TOKEN }}
3959

4060
- name: Publish Component ${{ inputs.component-name }}
41-
# Trigger workflow only for kubeflow/katib repository with specific branch (master, release-.*) or tag (v.*).
42-
if: >-
43-
github.repository == 'kubeflow/katib' &&
44-
(github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-') || startsWith(github.ref, 'refs/tags/v'))
61+
if: steps.publish-condition.outputs.should_publish == 'true'
4562
id: publish
4663
uses: ./.github/workflows/template-publish-image
4764
with:
48-
image: docker.io/kubeflowkatib/${{ inputs.component-name }}
65+
image: |
66+
ghcr.io/kubeflow/katib/${{ inputs.component-name }}
67+
docker.io/kubeflowkatib/${{ inputs.component-name }}
4968
dockerfile: ${{ inputs.dockerfile }}
5069
platforms: ${{ inputs.platforms }}
5170
push: true
@@ -54,7 +73,9 @@ jobs:
5473
if: steps.publish.outcome == 'skipped'
5574
uses: ./.github/workflows/template-publish-image
5675
with:
57-
image: docker.io/kubeflowkatib/${{ inputs.component-name }}
76+
image: |
77+
ghcr.io/kubeflow/katib/${{ inputs.component-name }}
78+
docker.io/kubeflowkatib/${{ inputs.component-name }}
5879
dockerfile: ${{ inputs.dockerfile }}
5980
platforms: ${{ inputs.platforms }}
6081
push: false

0 commit comments

Comments
 (0)