Skip to content

Commit

Permalink
feat(release.yml): add GitHub Actions workflow for publishing Docker …
Browse files Browse the repository at this point in the history
…image on release event

feat(test.yml): add GitHub Actions workflow for building and testing the code on push and pull_request events
chore(Chart.yaml): update version to 0.2.1 in the Kubernetes Event Exporter Helm chart
chore(role.yaml): add conditional logic to include namespace in Role metadata if rbac.namespaced is true
chore(rolebinding.yaml): add conditional logic to include namespace in RoleBinding metadata if rbac.namespaced is true
  • Loading branch information
jacobredesign committed Jun 30, 2023
1 parent eb98980 commit 2a5911c
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 4 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish Docker image

on:
release:
types: [published]

jobs:
push_to_registries:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
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

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: |
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Test
on: [push, pull_request]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.19
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Build
run: go build -v .

- name: Test
run: go test ./...
2 changes: 1 addition & 1 deletion charts/kubernetes-event-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ apiVersion: v2
name: kubernetes-event-exporter
description: Export Kubernetes events to multiple destinations with routing and filtering
type: application
version: 0.2.3
version: 0.2.1
appVersion: "v1.1"
home: https://github.com/resmoio/kubernetes-event-exporter
4 changes: 3 additions & 1 deletion charts/kubernetes-event-exporter/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: {{ .Values.rbac.namespaced | ternary "Role" "ClusterRole" }}
metadata:
namespace: {{ include "kubernetes-event-exporter.namespace" . }}
name: {{ include "kubernetes-event-exporter.fullname" . }}
labels:
{{- include "kubernetes-event-exporter.labels" . | nindent 4 }}
{{- if .Values.rbac.namespaced }}
namespace: {{ include "kubernetes-event-exporter.namespace" . }}
{{- end }}
rules:
{{ toYaml .Values.rbac.rules }}
{{- end -}}
8 changes: 6 additions & 2 deletions charts/kubernetes-event-exporter/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: {{ .Values.rbac.namespaced | ternary "RoleBinding" "ClusterRoleBinding" }}
metadata:
name: {{ include "kubernetes-event-exporter.fullname" . }}
namespace: {{ include "kubernetes-event-exporter.namespace" . }}
labels:
{{- include "kubernetes-event-exporter.labels" . | nindent 4 }}
{{- include "kubernetes-event-exporter.labels" . | nindent 4 }}
{{- if .Values.rbac.namespaced }}
namespace: {{ include "kubernetes-event-exporter.namespace" . }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: {{ .Values.rbac.namespaced | ternary "Role" "ClusterRole" }}
name: {{ include "kubernetes-event-exporter.fullname" . }}
subjects:
- kind: ServiceAccount
{{- if .Values.rbac.namespaced }}
namespace: {{ include "kubernetes-event-exporter.namespace" . }}
{{- end }}
name: {{ include "kubernetes-event-exporter.fullname" . }}
{{- end }}

0 comments on commit 2a5911c

Please sign in to comment.