Skip to content

Commit

Permalink
github: add workflow for building and pushing images
Browse files Browse the repository at this point in the history
We only build and push the bundle image for now.

Signed-off-by: Raghavendra Talur <[email protected]>
  • Loading branch information
raghavendra-talur authored and ShyamsundarR committed May 3, 2024
1 parent 117578c commit 7429050
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/buildpush.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
name: Build and push container images

on:
push:

env:
IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY || 'quay.io' }}
IMAGE_REPOSITORY: ${{ vars.IMAGE_REPOSITORY || 'ramendr' }}
IMAGE_NAME: ${{ vars.IMAGE_NAME || 'recipe' }}
IMAGE_TAG: "latest"
GO_VERSION: "1.19"
DOCKERCMD: "podman"

defaults:
run:
shell: bash

jobs:
build-and-push-image:
name: Build image
runs-on: ubuntu-latest
if: vars.PUBLISH_IMAGES == 'true'
steps:
- name: Checkout source
uses: actions/checkout@v3

- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Login to Quay
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}

- name: Determine image tag
run: |
[[ "${{ github.ref }}" =~ ^refs\/(heads|tags)\/(release-)?(.*) ]]
echo "heads or tags? ${BASH_REMATCH[1]}"
echo "release? ${BASH_REMATCH[2]}"
echo "version? ${BASH_REMATCH[3]}"
TAG=""
if test "${BASH_REMATCH[1]}" = "heads"; then
if test "${BASH_REMATCH[2]}" = "" && test "${BASH_REMATCH[3]}" = "main"; then
TAG="latest"
elif test "${BASH_REMATCH[2]}" = "release-"; then
TAG="${BASH_REMATCH[3]}-latest"
fi
elif test "${BASH_REMATCH[1]}" == "tags" && test "${BASH_REMATCH[2]}" = ""; then
TAG="${BASH_REMATCH[3]}"
fi
test "${TAG}" = "" && exit 1
echo "IMAGE_TAG is ${TAG}"
echo "IMAGE_TAG=${TAG}" >> $GITHUB_ENV
- name: Build and push crd bundle images to Quay
run: |
make crd-bundle-build crd-bundle-push

0 comments on commit 7429050

Please sign in to comment.