Skip to content

Commit

Permalink
refactor CI
Browse files Browse the repository at this point in the history
  • Loading branch information
karitham committed Jul 17, 2024
1 parent a9aa9ee commit ded88c1
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 128 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build and Push Docker Image

on:
push:
branches:
- main
tags:
- "*"

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push latest image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ghcr.io/kraudcloud/wga:latest

- name: Build and push tagged image
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ghcr.io/kraudcloud/wga:${{ github.ref_name }}
34 changes: 34 additions & 0 deletions .github/workflows/helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release Charts

on:
push:
tags:
- "*"

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Sed version
run: |
sed -i "s/appVersion:.*/appVersion: ${{ github.ref_name }}/" charts/wga/Chart.yaml
sed -i "s/version:.*/version: ${{ github.ref_name }}/" charts/wga/Chart.yaml
- name: Run chart-releaser
uses: Karitham/helm-oci-chart-releaser@b720e7e58d9e73b06f71f027ab61b54cb46b0964
with:
name: wga
tag: ${{ github.ref_name }}-helm
path: ./charts/wga
registry: ghcr.io
repository: wga
registry_username: kraudcloud
registry_password: ${{ secrets.GITHUB_TOKEN }}
45 changes: 0 additions & 45 deletions .github/workflows/publish.yaml

This file was deleted.

11 changes: 11 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: CI

on:
push:

jobs:
unittest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: d3adb5/helm-unittest-action@v2
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.debug
__snapshot__
103 changes: 48 additions & 55 deletions README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions charts/wga/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
.idea/
*.tmproj
.vscode/
# Tests
tests
4 changes: 2 additions & 2 deletions charts/wga/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.6.0
version: 0.0.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.6.0"
appVersion: "0.0.1"

icon: https://github.com/kraudcloud/wga/blob/0.6.0/docs/bobr.png?raw=true
7 changes: 7 additions & 0 deletions charts/wga/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ Create chart name and version as used by the chart label.
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Endpoint image
*/}}
{{- define "wga.endpointImage" -}}
{{- printf "%s:%s" .Values.endpoint.image.name (coalesce .Values.endpoint.image.tag .Chart.AppVersion .Chart.Version)}}
{{- end -}}

{{/*
Common labels
*/}}
Expand Down
4 changes: 2 additions & 2 deletions charts/wga/templates/endpoint/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
spec:
serviceAccountName: {{include "wga.serviceAccountName" .}}
containers:
- image: "{{- .Values.global.imageRegistry }}/{{- .Values.endpoint.image.name -}}:{{- default .Chart.AppVersion .Values.endpoint.image.tag }}"
- image: {{ include "wga.endpointImage" . }}
{{- if.Values.endpoint.image.pullPolicy }}
imagePullPolicy: {{.Values.endpoint.image.pullPolicy }}
{{- end }}
Expand All @@ -49,7 +49,7 @@ spec:
{{- if .Values.unbound.ip }}
value: {{ .Values.unbound.ip }}
{{- else }}
{{- fail "You must set endpoint.unbound.ip"}}
{{- fail "You must set unbound.ip"}}
{{- end }}
- name: WGA_ALLOWED_IPS
value: {{join "," .Values.endpoint.allowedIPs}}
Expand Down
4 changes: 2 additions & 2 deletions charts/wga/templates/unbound/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
spec:
restartPolicy: Always
containers:
- image: "{{- .Values.global.imageRegistry }}/{{- .Values.endpoint.image.name -}}:{{- default .Chart.AppVersion .Values.endpoint.image.tag }}"
- image: "{{ include "wga.endpointImage" . }}"
name: unbound
command:
- /usr/sbin/unbound
Expand All @@ -27,7 +27,7 @@ spec:
- containerPort: 53
name: dns
protocol: UDP
- image: "{{- .Values.global.privateImageRegistry }}/{{- .Values.unbound.welcomeImage.name -}}:{{- .Values.unbound.welcomeImage.tag }}"
- image: "{{- .Values.unbound.welcomeImage.name -}}:{{- .Values.unbound.welcomeImage.tag }}"
name: wga-welcome
imagePullPolicy: {{.Values.unbound.welcomeImage.pullPolicy }}
ports:
Expand Down
2 changes: 1 addition & 1 deletion charts/wga/templates/web/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
spec:
serviceAccountName: {{include "wga.serviceAccountName" .}}
containers:
- image: "{{- .Values.global.imageRegistry }}/{{- .Values.web.image.name -}}:{{- .Values.web.image.tag }}"
- image: "{{- .Values.web.image.name -}}:{{- .Values.web.image.tag }}"
{{- if .Values.web.image.pullPolicy }}
imagePullPolicy: {{.Values.web.image.pullPolicy }}
{{- end }}
Expand Down
4 changes: 2 additions & 2 deletions charts/wga/templates/wgc/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ if .Values.clusterClient.enable }}
{{ if .Values.clusterClient.enabled }}
---
apiVersion: apps/v1
kind: DaemonSet
Expand All @@ -18,7 +18,7 @@ spec:
serviceAccountName: {{include "wga.serviceAccountName" .}}
hostNetwork: true
containers:
- image: "{{- .Values.global.imageRegistry }}/{{- .Values.endpoint.image.name -}}:{{- default .Chart.AppVersion .Values.endpoint.image.tag }}"
- image: "{{ include "wga.endpointImage" . }}"
{{- if.Values.endpoint.image.pullPolicy }}
imagePullPolicy: {{.Values.endpoint.image.pullPolicy }}
{{- end }}
Expand Down
15 changes: 15 additions & 0 deletions charts/wga/tests/endpoint_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
suite: test default image tags
templates:
- endpoint/deployment.yaml
tests:
- it: default image tags should equal to current appVersion
chart:
appVersion: 0.6.2
set:
endpoint.address: 192.168.1.1
endpoint.privateKeySecretName: wga-key
unbound.ip: 192.168.1.53
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: "ghcr.io/kraudcloud/wga:0.6.2"
26 changes: 7 additions & 19 deletions charts/wga/values.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
## @section Global parameters
## Global Docker image parameters
## Please, note that this will override the image parameters, including dependencies, configured to use the global value
## Current available global Docker image parameters: imageRegistry, imagePullSecrets and storageClass
##

## @param global.imageRegistry Global Docker image registry
## @param global.privateImageRegistry Global Docker image registry for private images
global:
imageRegistry: "ghcr.io/kraudcloud"
privateImageRegistry: "ctr.0x.pt/wga"

## @section Wireguard Endpoint parameters
##

Expand Down Expand Up @@ -47,12 +35,12 @@ endpoint:
labels: {}

## @param endpoint.image.name endpoint image name
## @param endpoint.image.tag endpoint image tag
## @param endpoint.image.tag [default: Release.appVersion] endpoint image tag
## @param endpoint.image.pullPolicy Image pull policy
##
image:
name: wga
tag: "0.6.0"
name: "ghcr.io/kraudcloud/wga"
tag: ""
pullPolicy: ""

resources: {}
Expand All @@ -72,7 +60,7 @@ endpoint:
##
web:
image:
name: "wga-frontend"
name: "ghcr.io/kraudcloud/wga-frontend"
tag: "main"
pullPolicy: ""

Expand Down Expand Up @@ -124,11 +112,11 @@ serviceAccount:
## @section Cluster client
##

## @param clusterClient.enable enable a daemonset to access other clusters wga via WireguardClusterClient CRD
## @param clusterClient.enabled enable a daemonset to access other clusters wga via WireguardClusterClient CRD
## @param clusterClient.resources CPU/Memory resource requests/limits for the clusterClient component
##
clusterClient:
enable: false
enabled: false
resources: {}
# requests:
# cpu: 10m
Expand All @@ -149,7 +137,7 @@ unbound:
enabled: true

welcomeImage:
name: "welcome-page"
name: "ctr.0x.pt/wga/welcome-page"
tag: "1.0.1"
pullPolicy: ""

Expand Down

0 comments on commit ded88c1

Please sign in to comment.