Skip to content

Commit c101731

Browse files
committed
[feature] migrate images to ghcr (kubeflow#2455)
* migrate Signed-off-by: mahdikhashan <[email protected]> * update path Signed-off-by: mahdikhashan <[email protected]> * pull manifest from ghcr Signed-off-by: mahdikhashan <[email protected]> * pull image from ghcr Signed-off-by: mahdikhashan <[email protected]> * add dockerhub publish as a job Signed-off-by: mahdikhashan <[email protected]> * update images and runner Signed-off-by: mahdikhashan <[email protected]> * revert: manifest changes Signed-off-by: mahdikhashan <[email protected]> --------- Signed-off-by: mahdikhashan <[email protected]> Signed-off-by: Mahdi Khashan <[email protected]>
1 parent aad6edc commit c101731

File tree

1 file changed

+65
-8
lines changed

1 file changed

+65
-8
lines changed

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

Lines changed: 65 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
- pull_request
66

77
jobs:
8-
build-and-publish:
9-
name: Build and Publish Images
8+
build-and-publish-to-ghcr:
9+
name: Build and Publish Images to Github Container Registry
1010
runs-on:
1111
labels: ubuntu-latest-16-cores
1212

@@ -31,25 +31,26 @@ jobs:
3131
- name: Checkout
3232
uses: actions/checkout@v4
3333

34-
- name: Docker Login
34+
- name: GHCR Login
3535
# Trigger workflow only for kubeflow/trainer repository with specific branch (master, release-*) or tag (v.*).
3636
if: >-
3737
github.repository == 'kubeflow/trainer' &&
3838
(github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-') || startsWith(github.ref, 'refs/tags/v'))
3939
uses: docker/login-action@v3
4040
with:
41-
username: ${{ secrets.DOCKERHUB_USERNAME }}
42-
password: ${{ secrets.DOCKERHUB_TOKEN }}
41+
registry: ghcr.io
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
4344

44-
- name: Publish Component ${{ matrix.component-name }}
45+
- name: Publish Component ${{ matrix.component-name }} to GHCR
4546
# Trigger workflow only for kubeflow/trainer repository with specific branch (master, release-*) or tag (v.*).
4647
if: >-
4748
github.repository == 'kubeflow/trainer' &&
4849
(github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-') || startsWith(github.ref, 'refs/tags/v'))
4950
id: publish
5051
uses: ./.github/workflows/template-publish-image
5152
with:
52-
image: docker.io/kubeflow/${{ matrix.component-name }}
53+
image: ghcr.io/kubeflow/trainer/${{ matrix.component-name }}
5354
dockerfile: ${{ matrix.dockerfile }}
5455
platforms: ${{ matrix.platforms }}
5556
context: ${{ matrix.context }}
@@ -59,7 +60,63 @@ jobs:
5960
if: steps.publish.outcome == 'skipped'
6061
uses: ./.github/workflows/template-publish-image
6162
with:
62-
image: docker.io/kubeflow/${{ matrix.component-name }}
63+
image: ghcr.io/kubeflow/trainer/${{ matrix.component-name }}
64+
dockerfile: ${{ matrix.dockerfile }}
65+
platforms: ${{ matrix.platforms }}
66+
context: ${{ matrix.context }}
67+
push: false
68+
69+
build-and-publish-to-dockerhub:
70+
name: Build and Publish Images to DockerHub
71+
runs-on:
72+
labels: ubuntu-latest-16-cores
73+
74+
strategy:
75+
fail-fast: false
76+
matrix:
77+
include:
78+
- component-name: trainer-controller-manager
79+
dockerfile: cmd/trainer-controller-manager/Dockerfile
80+
platforms: linux/amd64,linux/arm64,linux/ppc64le
81+
- component-name: model-initializer
82+
dockerfile: cmd/initializer/model/Dockerfile
83+
platforms: linux/amd64,linux/arm64
84+
- component-name: dataset-initializer
85+
dockerfile: cmd/initializer/dataset/Dockerfile
86+
platforms: linux/amd64,linux/arm64
87+
- component-name: torchtune-trainer
88+
dockerfile: cmd/trainers/torchtune/Dockerfile
89+
platforms: linux/amd64,linux/arm64
90+
91+
steps:
92+
- name: Docker Hub Login
93+
if: >-
94+
github.repository == 'kubeflow/trainer' &&
95+
(github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-') || startsWith(github.ref, 'refs/tags/v'))
96+
uses: docker/login-action@v3
97+
with:
98+
registry: docker.io
99+
username: ${{ secrets.DOCKER_USERNAME }}
100+
password: ${{ secrets.DOCKER_PASSWORD }}
101+
102+
- name: Publish Component ${{ matrix.component-name }} to Docker Hub
103+
if: >-
104+
github.repository == 'kubeflow/trainer' &&
105+
(github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-') || startsWith(github.ref, 'refs/tags/v'))
106+
id: publish-dockerhub
107+
uses: ./.github/workflows/template-publish-image
108+
with:
109+
image: docker.io/kubeflow/trainer/${{ matrix.component-name }}
110+
dockerfile: ${{ matrix.dockerfile }}
111+
platforms: ${{ matrix.platforms }}
112+
context: ${{ matrix.context }}
113+
push: true
114+
115+
- name: Test Build For Component ${{ matrix.component-name }}
116+
if: steps.publish.outcome == 'skipped'
117+
uses: ./.github/workflows/template-publish-image
118+
with:
119+
image: docker.io/kubeflow/trainer/${{ matrix.component-name }}
63120
dockerfile: ${{ matrix.dockerfile }}
64121
platforms: ${{ matrix.platforms }}
65122
context: ${{ matrix.context }}

0 commit comments

Comments
 (0)