-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mmahipal
committed
Nov 8, 2021
1 parent
d0b6c59
commit 55e2b44
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Operator Image | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
# github.repository as <account>/<repo> | ||
IMAGE: ${{ github.repository }} | ||
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Golang setup | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.16 | ||
id: go | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
# Login against a Docker registry except on PR | ||
# https://github.com/docker/login-action | ||
- name: Log into registry ${{ env.REGISTRY }} | ||
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# extract branch name | ||
- name: Extract branch name | ||
if: github.event_name != 'pull_request' | ||
run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> "$GITHUB_ENV" | ||
|
||
# extract branch name on pull request | ||
- name: Extract branch name | ||
if: github.event_name == 'pull_request' | ||
run: echo "BRANCH_NAME=${GITHUB_HEAD_REF}" >> "$GITHUB_ENV" | ||
|
||
# Build and push Operator image | ||
- name: Build and push Operator image | ||
run: | | ||
make generate | ||
make manifests | ||
IMAGE_NAME=${{ env.IMAGE }} | ||
IMAGE_NAME=${IMAGE,,} | ||
make docker-build IMG="${{ env.REGISTRY }}/${IMAGE_NAME}:${{ env.BRANCH_NAME }}" | ||
docker push "${{ env.REGISTRY }}/${IMAGE_NAME}:${{ env.BRANCH_NAME }}" | ||
docker rmi "${{ env.REGISTRY }}/${IMAGE_NAME}:${{ env.BRANCH_NAME }}" && docker system prune -f | ||
rm -rf bin/ |