From 65f4d1b160c138f7394b99e0b1a8bbb9bca9b24d Mon Sep 17 00:00:00 2001 From: Srihari Date: Fri, 7 Jul 2023 12:19:21 +0530 Subject: [PATCH] Create Github action for Image build and push --- .github/workflows/mcad-release.yml | 20 +++++++++++++++++++- .travis.yml | 2 -- Makefile | 15 +++++---------- README.md | 8 +++----- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/.github/workflows/mcad-release.yml b/.github/workflows/mcad-release.yml index b5480cb95..5b0bc60ff 100644 --- a/.github/workflows/mcad-release.yml +++ b/.github/workflows/mcad-release.yml @@ -1,4 +1,4 @@ -# This workflow will create a GitHub release tag +# This workflow will Build image and push to mcad quay repository and create a GitHub release tag name: mcad Release on: @@ -9,6 +9,11 @@ on: required: true default: 'v0.0.0-dev' type: string + quay-organization: + description: 'Quay organization used to push the built images to' + required: true + default: 'project-codeflare' + type: string jobs: release: @@ -20,6 +25,8 @@ jobs: steps: - name: checkout code uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: check tag format run: | @@ -41,3 +48,14 @@ jobs: env: GITHUB_TOKEN: ${{ github.token }} + - name: Build + run: make mcad-controller + + - name: Image Build and Push + env: + GIT_BRANCH: ${{ github.event.inputs.tag }} + TAG: release-${{ github.event.inputs.tag }} + run: | + make images -e GIT_BRANCH=$GIT_BRANCH TAG=$TAG + make push-images -e GIT_BRANCH=$GIT_BRANCH TAG=$TAG quay_repository=quay.io/${{ github.event.inputs.quay-organization }} quay_id=${{ secrets.QUAY_ID }} quay_token=${{ secrets.QUAY_TOKEN }} + diff --git a/.travis.yml b/.travis.yml index 6928d77e3..5c9fecac2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,8 +27,6 @@ script: - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then make images; fi' # Process 'make images' when running as a pull request - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then unset quay_repository && make images; fi' - # Process 'make push-images' when NOT a pull request - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then make push-images; fi' # Run the e2e and handle Travis condition where Travis fails on no output for 10 minutes. No output for 10 minutes # is fine for our test cases that waits for 10 minutes before requeuing a job. The other workaround was to # use 'travis_wait n' which unfortunately does not stream output until the very end so monitoring the Travis log diff --git a/Makefile b/Makefile index 16a540d39..3d960a54b 100644 --- a/Makefile +++ b/Makefile @@ -19,16 +19,11 @@ endif # Check for current branch name and update 'RELEASE_VER' and 'TAG' ifneq ($(strip $(GIT_BRANCH)),) - ifeq ($(shell echo $(GIT_BRANCH) | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$$'),$(GIT_BRANCH)) - RELEASE_VER:=${GIT_BRANCH} - TAG:=release-${TAG} - else - RELEASE_VER:= $(shell git describe --tags --abbrev=0) - TAG:=${TAG}${GIT_BRANCH} - # replace invalid characters that might exist in the branch name - TAG:=$(shell echo ${TAG} | sed 's/[^a-zA-Z0-9]/-/g') - TAG:=${TAG}-${RELEASE_VER} - endif + RELEASE_VER:= $(shell git describe --tags --abbrev=0) + TAG:=${TAG}${GIT_BRANCH} + # replace invalid characters that might exist in the branch name + TAG:=$(shell echo ${TAG} | sed 's/[^a-zA-Z0-9]/-/g') + TAG:=${TAG}-${RELEASE_VER} endif .PHONY: print-global-variables diff --git a/README.md b/README.md index 33ef3d2d5..828cd8662 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,11 @@ Refer to [deployment instructions here](./doc/deploy/deployment.md) on how to de 1. Run the [mcad-release.yml](https://github.com/project-codeflare/actions/workflows/mcad-release.yml) action under `Actions` by entering the new release version in the `Release tag` input field and click `Run workflow`. ![mcad-release](doc/images/mcad-release.png) -2. Verify that [mcad-release.yml](https://github.com/project-codeflare/actions/workflows/mcad-release.yml) action passed successfully. This workflow will create GitHub release tag. +2. Verify that [mcad-release.yml](https://github.com/project-codeflare/actions/workflows/mcad-release.yml) action passed successfully. The workflow will Build and push the image to [mcad-controller quay repository](https://quay.io/repository/project-codeflare/mcad-controller?tab=tags) with specified release version tag and create GitHub release tag. -3. The release tag then trigger the [image build/push pipeline](https://app.travis-ci.com/github/project-codeflare/multi-cluster-app-dispatcher/branches) and push the image to [mcad-controller quay repository](https://quay.io/repository/project-codeflare/mcad-controller?tab=tags) with specified release version tag. +3. Verify a new release is created on the [Releases page](https://github.com/project-codeflare/multi-cluster-app-dispatcher/releases). -4. Verify a new release is created on the [Releases page](https://github.com/project-codeflare/multi-cluster-app-dispatcher/releases) . - -5. The latest release changes should also reflect in the [mcad go package module](https://pkg.go.dev/github.com/project-codeflare/multi-cluster-app-dispatcher). +4. The latest release changes should also reflect in the [mcad go package module](https://pkg.go.dev/github.com/project-codeflare/multi-cluster-app-dispatcher). ## Tutorial