Skip to content

Commit

Permalink
github workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Milleri <[email protected]>
  • Loading branch information
lmilleri committed Feb 21, 2024
1 parent 10e6c48 commit 9d9faa5
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/docker-publish-latest-on-merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Publish operator latest image on push to main

# When an push to `main` happens, build and push the multi-arch operator image to latest

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
branches:
- main

env:

REGISTRY: quay.io
# github.repository as <account>/<repo>
# IMAGE_NAME: ${{ github.repository }}
IMAGE_NAME: rh_ee_lmilleri/kbs-operator


jobs:
build:

runs-on: ubuntu-22.04
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Login against a Docker registry
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_ID }}
password: ${{ secrets.QUAY_SECRET }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
# Build and push Docker image with Buildx
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
platforms: linux/amd64,linux/s390x
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
68 changes: 68 additions & 0 deletions .github/workflows/docker-publish-on-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Publish operator release image when tagged

# When an tag is created, build and push the multi-arch operator image with that version

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
tags:
- '*'

env:

REGISTRY: quay.io
# github.repository as <account>/<repo>
# IMAGE_NAME: ${{ github.repository }}
IMAGE_NAME: rh_ee_lmilleri/kbs-operator


jobs:
build:

runs-on: ubuntu-22.04
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_ID }}
password: ${{ secrets.QUAY_SECRET }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/s390x
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
23 changes: 23 additions & 0 deletions .github/workflows/gofmt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: gofmt
on:
pull_request:
branches:
- main

permissions:
contents: read

jobs:
gofmt:
name: gofmt
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true
- name: gofmt
run : |
gofmt -s -w .
git diff --exit-code
23 changes: 23 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: golangci-lint
on:
pull_request:
branches:
- main

permissions:
contents: read

jobs:
golangci:
name: lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: --timeout 300s
36 changes: 36 additions & 0 deletions .github/workflows/makefile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Makefile CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true

- name: Download controller-gen
run: make controller-gen

- name: Download kustomize
run: make kustomize

- name: Download envtest
run: make envtest

- name: Build controller
run: make build

- name: Build bundle
run: make bundle IMG=quay.io/confidential-containers/operator:latest

0 comments on commit 9d9faa5

Please sign in to comment.