Skip to content

Commit

Permalink
workflows (#6)
Browse files Browse the repository at this point in the history
Edit workflow to build images and release helm charts
  • Loading branch information
divergentluna authored Feb 4, 2024
1 parent bbf0040 commit 3a6b1bb
Show file tree
Hide file tree
Showing 26 changed files with 185 additions and 25 deletions.
91 changes: 69 additions & 22 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: ci
name: Lint, Test, Image Build and Chart release

on:
push:
Expand All @@ -13,53 +13,100 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 5m
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
- run: go test -v ./... -covermode=atomic -coverprofile=coverage.out
- uses: codecov/codecov-action@v3
with:
files: coverage.out
build:

build-main:
name: build
runs-on: ubuntu-latest
needs:
- lint
- test
steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v3
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- uses: docker/build-push-action@v2
- uses: docker/build-push-action@v5
with:
file: "Dockerfile"
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}

build-clients:
name: build
runs-on: ubuntu-latest
needs:
- lint
- test
strategy:
matrix:
dir: ["clients/proxy-client", "clients/harbor-client"]
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
file: "${{ matrix.dir }}/Dockerfile"
context: ${{ matrix.dir }}
platforms: linux/amd64
push: true
tags: ghcr.io/${{ github.repository }}/${{ matrix.dir }}:${{ github.sha }}

release:
name: release
runs-on: ubuntu-latest
needs:
- build-main
- build-clients
strategy:
matrix:
dir: ["deploymant", "clients/proxy-client", "clients/harbor-client"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v3

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
with:
charts_dir: ${{ matrix.dir }}
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: snappcloud-harbor-client
description: A Helm chart for Kubernetes
description: A Helm chart for snappcloud-harbor-client

type: application
version: 0.1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
replicaCount: 1

image:
repository: ghcr.io/snapp-incubator/snappcloud-status-backend
repository: ghcr.io/snapp-incubator/snappcloud-status-backend/clients/harbor-client
pullPolicy: Always
tag: "0.0.1"

Expand Down
7 changes: 7 additions & 0 deletions clients/proxy-client/charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: snappcloud-proxy-client
description: A Helm chart for snappcloud-proxy-client

type: application
version: 0.1.0
appVersion: "0.0.1"
46 changes: 46 additions & 0 deletions clients/proxy-client/charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "snappcloud-proxy-client.fullname" . }}
labels:
{{- include "snappcloud-proxy-client.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "snappcloud-proxy-client.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "snappcloud-proxy-client.selectorLabels" . | nindent 8 }}
annotations:
{{- .Values.podAnnotations | toYaml | nindent 8 }}
spec:
serviceAccountName: {{ include "snappcloud-proxy-client.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
env:
- name: PROXY_URL
valueFrom:
secretKeyRef:
name: {{ .Values.configSecretName }}
key: PROXY_URL
{{ .Values.nodeSelector | toYaml | nindent 8 }}
tolerations:
{{- with .Values.tolerations }}
{{- toYaml . | nindent 8 }}
{{- end }}
affinity:
{{- with .Values.affinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
9 changes: 9 additions & 0 deletions clients/proxy-client/charts/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.configSecretName }}
labels:
{{- include "snappcloud-proxy-client.labels" . | nindent 4 }}
type: Opaque
stringData:
PROXY_URL: "The proxy address."
14 changes: 14 additions & 0 deletions clients/proxy-client/charts/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "snappcloud-proxy-client.fullname" . }}
labels:
{{- include "snappcloud-proxy-client.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
selector:
{{- include "snappcloud-proxy-client.selectorLabels" . | nindent 4 }}
37 changes: 37 additions & 0 deletions clients/proxy-client/charts/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
replicaCount: 1

image:
repository: ghcr.io/snapp-incubator/snappcloud-status-backend/clients/proxy-client
pullPolicy: Always
tag: "0.0.1"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
create: false
automount: true
annotations: {}
name: ""

service:
type: ClusterIP
port: 8080

resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi

autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

configSecretName: spcld-proxy-health-client
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: snappcloud-status-backend
description: A Helm chart for Kubernetes
description: snappcloud-status-backend Helm chart

# A chart can be either an 'application' or a 'library' chart.
#
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3a6b1bb

Please sign in to comment.