Skip to content

Commit

Permalink
Added github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mmahipal committed Nov 8, 2021
1 parent d0b6c59 commit 55e2b44
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/github-actions.yml
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/

0 comments on commit 55e2b44

Please sign in to comment.