Skip to content

Commit 55e2b44

Browse files
author
mmahipal
committed
Added github actions
1 parent d0b6c59 commit 55e2b44

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

.github/workflows/github-actions.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Operator Image
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
# github.repository as <account>/<repo>
12+
IMAGE: ${{ github.repository }}
13+
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Golang setup
20+
uses: actions/setup-go@v1
21+
with:
22+
go-version: 1.16
23+
id: go
24+
25+
- name: Checkout repository
26+
uses: actions/checkout@v2
27+
28+
# Login against a Docker registry except on PR
29+
# https://github.com/docker/login-action
30+
- name: Log into registry ${{ env.REGISTRY }}
31+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
32+
with:
33+
registry: ${{ env.REGISTRY }}
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
# extract branch name
38+
- name: Extract branch name
39+
if: github.event_name != 'pull_request'
40+
run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> "$GITHUB_ENV"
41+
42+
# extract branch name on pull request
43+
- name: Extract branch name
44+
if: github.event_name == 'pull_request'
45+
run: echo "BRANCH_NAME=${GITHUB_HEAD_REF}" >> "$GITHUB_ENV"
46+
47+
# Build and push Operator image
48+
- name: Build and push Operator image
49+
run: |
50+
make generate
51+
make manifests
52+
IMAGE_NAME=${{ env.IMAGE }}
53+
IMAGE_NAME=${IMAGE,,}
54+
make docker-build IMG="${{ env.REGISTRY }}/${IMAGE_NAME}:${{ env.BRANCH_NAME }}"
55+
docker push "${{ env.REGISTRY }}/${IMAGE_NAME}:${{ env.BRANCH_NAME }}"
56+
docker rmi "${{ env.REGISTRY }}/${IMAGE_NAME}:${{ env.BRANCH_NAME }}" && docker system prune -f
57+
rm -rf bin/

0 commit comments

Comments
 (0)