Skip to content

Commit 514cafa

Browse files
Srihari1192openshift-merge-robot
authored andcommitted
Create a GitHub action for Build Image and push against main branch
1 parent c3bd25c commit 514cafa

File tree

4 files changed

+61
-59
lines changed

4 files changed

+61
-59
lines changed

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

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build and Push dev MCAD image into Quay
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+
if [[ "$BRANCH" == "main" ]]; then
23+
echo "TAG=dev" >> $GITHUB_ENV
24+
elif [[ "$BRANCH" == release-* ]]; then
25+
echo "TAG=dev-$BRANCH" >> $GITHUB_ENV
26+
else
27+
LATEST_TAG=$(git describe --abbrev=0 --tags)
28+
echo "TAG=$BRANCH-$LATEST_TAG" >> $GITHUB_ENV
29+
fi
30+
31+
- name: Set up Go
32+
uses: actions/setup-go@v3
33+
with:
34+
go-version: 1.19.10
35+
36+
- name: Build
37+
run:
38+
make mcad-controller
39+
40+
- name: Run Unit tests
41+
run: make run-test
42+
43+
- name: Build Image
44+
run: |
45+
make images -e GIT_BRANCH=${{ env.GIT_BRANCH }} TAG=${{ env.TAG }}
46+
47+
- name: Push Image
48+
run: |
49+
make push-images -e GIT_BRANCH=${{ env.GIT_BRANCH }} TAG=${{ env.TAG }} quay_repository=quay.io/project-codeflare quay_id=${{ secrets.QUAY_ID }} quay_token=${{ secrets.QUAY_TOKEN }}
50+
51+
- name: Run E2E tests
52+
run: |
53+
make run-e2e -e GIT_BRANCH=${{ env.GIT_BRANCH }} TAG=${{ env.TAG }}

Diff for: .travis.yml

-41
This file was deleted.

Diff for: Makefile

+2-11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ CAT_CMD=$(if $(filter $(OS),Windows_NT),type,cat)
33
RELEASE_VER:=
44
CURRENT_DIR=$(shell pwd)
55
GIT_BRANCH:=$(shell git symbolic-ref --short HEAD 2>&1 | grep -v fatal)
6+
67
#define the GO_BUILD_ARGS if you need to pass additional arguments to the go build
78
GO_BUILD_ARGS?=
89

@@ -22,16 +23,7 @@ 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-
3026
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
3527

3628
# Check for current branch name and update 'RELEASE_VER' and 'TAG'
3729
ifneq ($(strip $(GIT_BRANCH)),)
@@ -184,7 +176,6 @@ push-images: verify-tag-name
184176
ifeq ($(strip $(quay_repository)),)
185177
$(info No registry information provided. To push images to a docker registry please set)
186178
$(info environment variables: quay_repository, quay_token, and quay_id. Environment)
187-
$(info variables do not need to be set for github Travis CICD.)
188179
else
189180
$(info Log into quay)
190181
docker login quay.io -u ${quay_id} --password ${quay_token}
@@ -193,7 +184,7 @@ else
193184
$(info Push the docker image to registry)
194185
docker push ${quay_repository}/mcad-controller:${TAG}
195186
ifeq ($(strip $(git_repository_id)),main)
196-
$(info Update the `latest` tag when built from `main`)
187+
$(info Update the `dev` tag when built from `main`)
197188
docker tag mcad-controller:${TAG} ${quay_repository}/mcad-controller:latest
198189
docker push ${quay_repository}/mcad-controller:latest
199190
endif

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

+6-7
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,13 @@ 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
61+
which curl >/dev/null 2>&1
62+
if [ $? -ne 0 ]
63+
then
64+
echo "curl not installed, exiting."
65+
exit 1
6766
fi
68-
67+
6968
which kubectl >/dev/null 2>&1
7069
if [ $? -ne 0 ]
7170
then

0 commit comments

Comments
 (0)