Skip to content

Commit 5a71ea9

Browse files
committed
Create a GitHub action for Build Image and push against main branch
1 parent ab92337 commit 5a71ea9

File tree

4 files changed

+51
-74
lines changed

4 files changed

+51
-74
lines changed

Diff for: .github/workflows/build-and-push.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build and Push
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: checkout code
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set latest tag and Branch name
19+
run: |
20+
BRANCH=$(echo ${GITHUB_REF#refs/heads/})
21+
echo "GIT_BRANCH=$(echo "$BRANCH" | sed 's/[^A-Za-z0-9._-]/-/g' )" >> $GITHUB_ENV
22+
echo "TAG=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV
23+
24+
- name: Set up Go
25+
uses: actions/setup-go@v3
26+
with:
27+
go-version: 1.19.10
28+
29+
- name: Build
30+
run:
31+
make mcad-controller
32+
33+
- name: Run Unit tests
34+
run: make run-test
35+
36+
- name: Build Image
37+
run: |
38+
make images -e GIT_BRANCH=${{ env.GIT_BRANCH }} TAG=${{ env.GIT_BRANCH }}-${{ env.TAG }}
39+
40+
- name: Push Image
41+
run: |
42+
make push-images -e GIT_BRANCH=${{ env.GIT_BRANCH }} TAG=${{ env.GIT_BRANCH }}-${{ env.TAG }} quay_repository=quay.io/project-codeflare quay_id=${{ secrets.QUAY_ID }} quay_token=${{ secrets.QUAY_TOKEN }}
43+
44+
- name: Run E2E tests
45+
run: |
46+
make run-e2e -e GIT_BRANCH=${{ env.GIT_BRANCH }} TAG=${{ env.GIT_BRANCH }}-${{ env.TAG }}

Diff for: .travis.yml

-41
This file was deleted.

Diff for: Makefile

+5-25
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
BIN_DIR=_output/bin
22
CAT_CMD=$(if $(filter $(OS),Windows_NT),type,cat)
3-
RELEASE_VER:=
3+
RELEASE_VER:=$(shell git describe --tags --abbrev=0)
44
CURRENT_DIR=$(shell pwd)
55
GIT_BRANCH:=$(shell git symbolic-ref --short HEAD 2>&1 | grep -v fatal)
6+
TAG:=
67
#define the GO_BUILD_ARGS if you need to pass additional arguments to the go build
78
GO_BUILD_ARGS?=
89

@@ -22,26 +23,6 @@ CLIENT_GEN ?= $(LOCALBIN)/client-gen
2223
LISTER_GEN ?= $(LOCALBIN)/lister-gen
2324
INFORMER_GEN ?= $(LOCALBIN)/informer-gen
2425

25-
# Reset branch name if this a Travis CI environment
26-
ifneq ($(strip $(TRAVIS_BRANCH)),)
27-
GIT_BRANCH:=${TRAVIS_BRANCH}
28-
endif
29-
30-
TAG:=$(shell echo "")
31-
# Check for git repository id sent by Travis-CI
32-
ifneq ($(strip $(git_repository_id)),)
33-
TAG:=${TAG}${git_repository_id}-
34-
endif
35-
36-
# Check for current branch name and update 'RELEASE_VER' and 'TAG'
37-
ifneq ($(strip $(GIT_BRANCH)),)
38-
RELEASE_VER:= $(shell git describe --tags --abbrev=0)
39-
TAG:=${TAG}${GIT_BRANCH}
40-
# replace invalid characters that might exist in the branch name
41-
TAG:=$(shell echo ${TAG} | sed 's/[^a-zA-Z0-9]/-/g')
42-
TAG:=${TAG}-${RELEASE_VER}
43-
endif
44-
4526
.PHONY: print-global-variables
4627

4728
# Build the controller executable for use in docker image build
@@ -184,7 +165,6 @@ push-images: verify-tag-name
184165
ifeq ($(strip $(quay_repository)),)
185166
$(info No registry information provided. To push images to a docker registry please set)
186167
$(info environment variables: quay_repository, quay_token, and quay_id. Environment)
187-
$(info variables do not need to be set for github Travis CICD.)
188168
else
189169
$(info Log into quay)
190170
docker login quay.io -u ${quay_id} --password ${quay_token}
@@ -193,9 +173,9 @@ else
193173
$(info Push the docker image to registry)
194174
docker push ${quay_repository}/mcad-controller:${TAG}
195175
ifeq ($(strip $(git_repository_id)),main)
196-
$(info Update the `latest` tag when built from `main`)
197-
docker tag mcad-controller:${TAG} ${quay_repository}/mcad-controller:latest
198-
docker push ${quay_repository}/mcad-controller:latest
176+
$(info Update the `dev` tag when built from `main`)
177+
docker tag mcad-controller:${TAG} ${quay_repository}/mcad-controller:dev
178+
docker push ${quay_repository}/mcad-controller:dev
199179
endif
200180
ifneq ($(TAG:release-v%=%),$(TAG))
201181
$(info Update the `stable` tag to point `latest` release image)

Diff for: hack/run-e2e-kind.sh

-8
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,6 @@ function update_test_host {
5858
fi
5959
echo "CPU architecture for downloads is: ${arch}"
6060

61-
#Only run this function if we are running on the travis build machinbe,
62-
if [ "$(lsb_release -c -s 2>&1 | grep xenial)" == "xenial" ]; then
63-
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
64-
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
65-
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
66-
sudo apt-get update
67-
fi
68-
6961
which kubectl >/dev/null 2>&1
7062
if [ $? -ne 0 ]
7163
then

0 commit comments

Comments
 (0)