Skip to content

Commit 7434914

Browse files
authored
Merge pull request #307 from ykulazhenkov/pr-gh-actions
Add github actions to publish images to GH registry
2 parents 10d2594 + 98a60a4 commit 7434914

File tree

6 files changed

+155
-5
lines changed

6 files changed

+155
-5
lines changed
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: image-build-test
2+
on: [push, pull_request]
3+
4+
env:
5+
BUILD_PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le
6+
7+
jobs:
8+
build-image:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out the repo
12+
uses: actions/checkout@v4
13+
14+
# Add support for more platforms with QEMU (optional)
15+
# https://github.com/docker/setup-qemu-action
16+
- name: Set up QEMU
17+
uses: docker/setup-qemu-action@v3
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
22+
- name: Prepare version file
23+
run: ./hack/get_version.sh > .version
24+
25+
- name: Build and push container image
26+
uses: docker/build-push-action@v5
27+
with:
28+
context: .
29+
push: false
30+
# no need to explicitly set goarch,
31+
# correct arch will be selected for each build platform
32+
build-args: |
33+
goarch=
34+
platforms: ${{ env.BUILD_PLATFORMS }}
35+
file: ./cmd/Dockerfile
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: "Push images on merge to main"
2+
3+
env:
4+
IMAGE_NAME: ghcr.io/${{ github.repository }}-plugin
5+
BUILD_PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
build-and-push-image:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out the repo
17+
uses: actions/checkout@v4
18+
19+
# Add support for more platforms with QEMU (optional)
20+
# https://github.com/docker/setup-qemu-action
21+
- name: Set up QEMU
22+
uses: docker/setup-qemu-action@v3
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Login to Docker
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.repository_owner }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Docker meta
35+
id: docker_meta
36+
uses: docker/metadata-action@v5
37+
with:
38+
images: ${{ env.IMAGE_NAME }}
39+
40+
- name: Prepare version file
41+
run: ./hack/get_version.sh > .version
42+
43+
- name: Build and push container image
44+
uses: docker/build-push-action@v5
45+
with:
46+
context: .
47+
push: true
48+
# no need to explicitly set goarch,
49+
# correct arch will be selected for each build platform
50+
build-args: |
51+
goarch=
52+
platforms: ${{ env.BUILD_PLATFORMS }}
53+
tags: |
54+
${{ env.IMAGE_NAME }}:latest
55+
${{ env.IMAGE_NAME }}:${{ github.sha }}
56+
file: ./cmd/Dockerfile
57+
labels: ${{ steps.docker_meta.outputs.labels }}
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: "Push images on release"
2+
3+
env:
4+
IMAGE_NAME: ghcr.io/${{ github.repository }}-plugin
5+
BUILD_PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le
6+
7+
on:
8+
push:
9+
tags:
10+
- v*
11+
12+
jobs:
13+
build-and-push-image:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out the repo
17+
uses: actions/checkout@v4
18+
19+
# Add support for more platforms with QEMU (optional)
20+
# https://github.com/docker/setup-qemu-action
21+
- name: Set up QEMU
22+
uses: docker/setup-qemu-action@v3
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Login to Docker
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.repository_owner }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Docker meta
35+
id: docker_meta
36+
uses: docker/metadata-action@v5
37+
with:
38+
images: ${{ env.IMAGE_NAME }}
39+
flavor: |
40+
latest=false
41+
42+
- name: Prepare version file
43+
run: ./hack/get_version.sh > .version
44+
45+
- name: Build and push container image
46+
uses: docker/build-push-action@v5
47+
with:
48+
context: .
49+
push: true
50+
# no need to explicitly set goarch,
51+
# correct arch will be selected for each build platform
52+
build-args: |
53+
goarch=
54+
platforms: ${{ env.BUILD_PLATFORMS }}
55+
tags: |
56+
${{ steps.docker_meta.outputs.tags }}
57+
labels: ${{ steps.docker_meta.outputs.labels }}
58+
file: ./cmd/Dockerfile

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
REGISTRY ?= quay.io/kubevirt
1+
REGISTRY ?= ghcr.io/k8snetworkplumbingwg
22
IMAGE_TAG ?= latest
33
IMAGE_GIT_TAG ?= $(shell git describe --abbrev=8 --tags)
44

cluster/sync.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ REGISTRY=$registry make docker-push
3636

3737
ovs_cni_manifest="./examples/ovs-cni.yml"
3838

39-
sed 's/quay.io\/kubevirt/registry:5000/g' examples/ovs-cni.yml | ./cluster/kubectl.sh delete --ignore-not-found -f -
39+
sed 's/ghcr.io\/k8snetworkplumbingwg/registry:5000/g' examples/ovs-cni.yml | ./cluster/kubectl.sh delete --ignore-not-found -f -
4040

4141
# Delete daemon sets that were deprecated/renamed
4242
./cluster/kubectl.sh -n kube-system delete --ignore-not-found ds ovs-cni-plugin-amd64
@@ -50,4 +50,4 @@ until [ $(check_deleted "-f $ovs_cni_manifest") -eq 1 ]; do sleep 1; done
5050
until [ $(check_deleted "ds ovs-cni-plugin-amd64") -eq 1 ]; do sleep 1; done
5151
until [ $(check_deleted "ds ovs-vsctl-amd64") -eq 1 ]; do sleep 1; done
5252

53-
sed 's/quay.io\/kubevirt/registry:5000/g' examples/ovs-cni.yml | ./cluster/kubectl.sh apply -f -
53+
sed 's/ghcr.io\/k8snetworkplumbingwg/registry:5000/g' examples/ovs-cni.yml | ./cluster/kubectl.sh apply -f -

examples/ovs-cni.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ spec:
3333
effect: NoSchedule
3434
initContainers:
3535
- name: ovs-cni-plugin
36-
image: quay.io/kubevirt/ovs-cni-plugin:latest
36+
image: ghcr.io/k8snetworkplumbingwg/ovs-cni-plugin:latest
3737
command: ["/bin/sh","-c"]
3838
args:
3939
- >
@@ -53,7 +53,7 @@ spec:
5353
priorityClassName: system-node-critical
5454
containers:
5555
- name: ovs-cni-marker
56-
image: quay.io/kubevirt/ovs-cni-plugin:latest
56+
image: ghcr.io/k8snetworkplumbingwg/ovs-cni-plugin:latest
5757
imagePullPolicy: IfNotPresent
5858
securityContext:
5959
privileged: true

0 commit comments

Comments
 (0)