1+ name : On-demand build
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ branch :
7+ description : ' Branch to checkout'
8+ required : true
9+ default : ' main'
10+ version :
11+ description : ' image version'
12+ required : true
13+ go_version :
14+ description : ' go version'
15+ required : true
16+
17+ env :
18+ GO_VERSION : ${{ github.event.inputs.go_version }}
19+ VERSION : ${{ github.event.inputs.version }}
20+ IMAGE_REGISTRY : ghcr.io/${{ github.repository_owner }}
21+ DAEMON_REGISTRY : ghcr.io/${{ github.repository_owner }}
22+
23+ jobs :
24+ build-push-controller :
25+ runs-on : ubuntu-latest
26+ env :
27+ IMAGE_NAME : ghcr.io/${{ github.repository }}-controller
28+ steps :
29+ - name : Checkout selected branch
30+ uses : actions/checkout@v4
31+ with :
32+ ref : ${{ github.event.inputs.branch }}
33+ - uses : actions/setup-go@v2
34+ with :
35+ go-version : ${{ env.GO_VERSION }}
36+ - name : Tidy
37+ run : |
38+ go mod tidy
39+ make generate fmt vet
40+ - name : Set up Docker
41+ uses : docker/setup-buildx-action@v1
42+ - name : Login to Docker
43+ uses : docker/login-action@v1
44+ with :
45+ registry : ghcr.io
46+ username : ${{ secrets.GH_USERNAME }}
47+ password : ${{ secrets.GHCR_TOKEN }}
48+ - name : Build and push controller
49+ uses : docker/build-push-action@v2
50+ with :
51+ context : .
52+ push : true
53+ tags : |
54+ ${{ env.IMAGE_NAME }}:v${{ env.VERSION }}
55+ file : ./Dockerfile
56+ build-push-bundle :
57+ runs-on : ubuntu-latest
58+ needs : build-push-controller
59+ env :
60+ BUNDLE_IMAGE_NAME : ghcr.io/${{ github.repository }}-bundle
61+ CHANNELS : beta
62+ steps :
63+ - name : Checkout selected branch
64+ uses : actions/checkout@v4
65+ with :
66+ ref : ${{ github.event.inputs.branch }}
67+ - uses : actions/setup-go@v2
68+ with :
69+ go-version : ${{ env.GO_VERSION }}
70+ - name : set ARCH and OD
71+ run : |
72+ echo "ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)" >> $GITHUB_ENV
73+ echo "OS=$(uname | awk '{print tolower($0)}')" >> $GITHUB_ENV
74+ echo "OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.39.2" >> $GITHUB_ENV
75+ - name : download operator-sdk
76+ run : curl -LO ${{ env.OPERATOR_SDK_DL_URL }}/operator-sdk_${{ env.OS }}_${{ env.ARCH }}
77+ - name : move operator-sdk to binary path
78+ run : chmod +x operator-sdk_${{ env.OS }}_${{ env.ARCH }} && sudo mv operator-sdk_${{ env.OS }}_${{ env.ARCH }} /usr/local/bin/operator-sdk
79+ - name : Tidy
80+ run : |
81+ go mod tidy
82+ - name : Make bundle
83+ run : make bundle
84+ - name : Set up Docker
85+ uses : docker/setup-buildx-action@v1
86+ - name : Login to Docker
87+ uses : docker/login-action@v1
88+ with :
89+ registry : ghcr.io
90+ username : ${{ secrets.GH_USERNAME }}
91+ password : ${{ secrets.GHCR_TOKEN }}
92+ - name : Build and push bundle
93+ uses : docker/build-push-action@v2
94+ with :
95+ context : .
96+ push : true
97+ tags : |
98+ ${{ env.BUNDLE_IMAGE_NAME }}:v${{ env.VERSION }}
99+ file : ./bundle.Dockerfile
100+ build-push-daemon :
101+ runs-on : ubuntu-latest
102+ env :
103+ IMAGE_NAME : ghcr.io/${{ github.repository }}-daemon
104+ steps :
105+ - name : Checkout selected branch
106+ uses : actions/checkout@v4
107+ with :
108+ ref : ${{ github.event.inputs.branch }}
109+ - uses : actions/setup-go@v2
110+ with :
111+ go-version : ${{ env.GO_VERSION }}
112+ - name : Set up Docker
113+ uses : docker/setup-buildx-action@v1
114+ - name : Update CNI
115+ run : make update-cni-local
116+ working-directory : daemon
117+ - name : Login to Docker
118+ uses : docker/login-action@v1
119+ with :
120+ registry : ghcr.io
121+ username : ${{ secrets.GH_USERNAME }}
122+ password : ${{ secrets.GHCR_TOKEN }}
123+ - name : Build and push daemon
124+ uses : docker/build-push-action@v2
125+ with :
126+ context : daemon
127+ push : true
128+ tags : |
129+ ${{ env.IMAGE_NAME }}:v${{ env.VERSION }}
130+ file : ./daemon/dockerfiles/Dockerfile
0 commit comments