Skip to content

Commit

Permalink
Prepare preview environments
Browse files Browse the repository at this point in the history
  • Loading branch information
oscrx committed Aug 6, 2023
1 parent e50cd03 commit 4e06394
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 39 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ jobs:
tags: |
type=ref,event=branch
type=sha
flavor: |
latest=auto
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand All @@ -115,10 +113,10 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: ${{ matrix.folder }}
push: ${{ github.event_name != 'pull_request' }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
Expand Down Expand Up @@ -146,12 +144,12 @@ jobs:
# Trim the first few characters to match the desired format (e.g., sha-c27d339)
SHORT_SHA="sha-${COMMIT_SHA:0:7}"
# Change appVersion in charts/drinkn/Chart.yaml
sed -i "s|appVersion:.*|appVersion: \"$SHORT_SHA\"|" charts/drinkn/Chart.yaml
# Change image.tag in charts/drinkn/values.yaml
sed -i "s|tag:.*|tag: \"$SHORT_SHA\"|" charts/drinkn/values.yaml
# Commit and push the changes to the deploy branch
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add charts/drinkn/Chart.yaml
git commit -m "Update appVersion to $SHORT_SHA"
git add charts/drinkn/values.yaml
git commit -m "Update image.tag to $SHORT_SHA"
git push origin main
19 changes: 0 additions & 19 deletions charts/drinkn/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
apiVersion: v2
name: drinkn
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
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: 1.0.0

# 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: "sha-e65db8c"
4 changes: 3 additions & 1 deletion charts/drinkn/templates/auth-api.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.pr.enabled }}
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -6,7 +7,7 @@ metadata:
app: drinkn-auth
name: drinkn-auth
spec:
replicas: 2
replicas: {{ .Values.replicas }}
revisionHistoryLimit: 0
selector:
matchLabels:
Expand Down Expand Up @@ -39,3 +40,4 @@ spec:
name: default
protocol: TCP
targetPort: 3000
{{- end }}
4 changes: 3 additions & 1 deletion charts/drinkn/templates/beer-import.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.pr.enabled }} # maybe mock a fake api to run against?
---
apiVersion: batch/v1
kind: CronJob
Expand All @@ -11,7 +12,7 @@ spec:
restartPolicy: Never
terminationGracePeriodSeconds: 30
containers:
- image: "ghcr.io/bierteam/drinkn/beer-import:{{ .Chart.AppVersion }}"
- image: "ghcr.io/bierteam/drinkn/beer-import:{{ .Values.image.tag }}"
imagePullPolicy: Always
name: beer-import
envFrom:
Expand All @@ -21,3 +22,4 @@ spec:
schedule: 0 9,22 * * *
failedJobsHistoryLimit: 3
successfulJobsHistoryLimit: 3
{{- end }}
4 changes: 3 additions & 1 deletion charts/drinkn/templates/cocktail-api.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.pr.enabled }}
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -6,7 +7,7 @@ metadata:
app: drinkn-cocktail-api
name: drinkn-cocktail-api
spec:
replicas: 2
replicas: {{ .Values.replicas }}
revisionHistoryLimit: 0
selector:
matchLabels:
Expand Down Expand Up @@ -39,3 +40,4 @@ spec:
name: default
protocol: TCP
targetPort: 3000
{{- end }}
4 changes: 3 additions & 1 deletion charts/drinkn/templates/drinkn-frontend.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.pr.enabled }}
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -6,7 +7,7 @@ metadata:
app: drinkn-frontend
name: drinkn-frontend
spec:
replicas: 2
replicas: {{ .Values.replicas }}
revisionHistoryLimit: 0
selector:
matchLabels:
Expand Down Expand Up @@ -55,3 +56,4 @@ spec:
name: default
protocol: TCP
targetPort: 80
{{- end }}
6 changes: 4 additions & 2 deletions charts/drinkn/templates/ingressroute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ spec:
entryPoints:
- websecure
routes:
{{- if not .Values.pr.enabled }}
- match: Host(`drinkn.oscarr.nl`, `xn--xj8haa.tk`)
kind: Rule
services:
Expand All @@ -32,12 +33,13 @@ spec:
services:
- name: drinkn-auth
port: 80
- match: Host(`pils.oscarr.nl`)
{{- end }}
- match: Host(`{{ .Values.fqdn }}`)
kind: Rule
services:
- name: pils-frontend
port: 80
- match: Host(`pils.oscarr.nl`) && PathPrefix(`/api`)
- match: Host(`{{ .Values.fqdn }}`) && PathPrefix(`/api`)
kind: Rule
services:
- name: pils
Expand Down
8 changes: 8 additions & 0 deletions charts/drinkn/templates/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- if .Values.pr.enabled }}
# https://github.com/argoproj/argo-cd/issues/7875#issuecomment-1178931205
---
apiVersion: v1
kind: Namespace
metadata:
name: drinkn-pr-{{.Values.pr.number}}
{{- end }}
4 changes: 2 additions & 2 deletions charts/drinkn/templates/pils-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
app: pils
name: pils
spec:
replicas: 2
replicas: {{ .Values.replicas }}
revisionHistoryLimit: 0
selector:
matchLabels:
Expand All @@ -19,7 +19,7 @@ spec:
app: pils
spec:
containers:
- image: "ghcr.io/bierteam/drinkn/pils:{{ .Chart.AppVersion }}"
- image: ghcr.io/bierteam/drinkn/pils:{{ .Values.image.tag }}
envFrom:
- secretRef:
name: drinkn-env
Expand Down
4 changes: 2 additions & 2 deletions charts/drinkn/templates/pils-frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
app: pils-frontend
name: pils-frontend
spec:
replicas: 2
replicas: {{ .Values.replicas }}
revisionHistoryLimit: 0
selector:
matchLabels:
Expand All @@ -19,7 +19,7 @@ spec:
app: pils-frontend
spec:
containers:
- image: "ghcr.io/bierteam/drinkn/pils-frontend:{{ .Chart.AppVersion }}"
- image: ghcr.io/bierteam/drinkn/pils-frontend:{{ .Values.image.tag }}
imagePullPolicy: Always
name: pils-frontend
---
Expand Down
4 changes: 4 additions & 0 deletions charts/drinkn/templates/secrets.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.pr.enabled }}
---
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
Expand All @@ -17,3 +18,6 @@ spec:
HIIPERUSER: AgAbuIWvk/Ymr2/Qafzzts885R+IiWrqBKPjgWM9PUY93SkxdCtJw4kYAgpaa13hAN0P/hePkFhD1Fh+bnnXAcz10cWlqUqEsBQAVyZdlZ4IhXAfnbb1FqDVAtHMPCf6LawjCFpWI0JryRpUAEtHfmoOzUXn2a0E74vcZ98UmecRdnNe/FH3cLV1vA0MayjtHL4ImfejGFz3nQiYMFNHgnjnwr1ulK0VLJlSNLwbkNwIX5rBGkorUFtvQ7s+rKJEwfJRscIFqoFpVQMHHMS6BDDIRWxk/ifPRXzjPXGydSh2LS5+xf5LB5d5t1xsfbiAAKVQL7Dch5M5RnTrZ8LH+O2W8b0u8vTImJfob6if7Uwb5Z+82hvMgHxI9lkf2dLJ3egEECOhPvknkHvAx38a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gYVXZ9SLre/Hdvc+t2wyW6jTYzwcvFEUJN87PiGhRleWh6r+LMvpn/LzBQPBnkS+mywNGv9ifW8+JOZK747DPb/NOSjulNUjLqyC6d/fH1SGK2n9clmSO1/lhxeCSpcvZABklAwjlxQ5hPgVjW2WrOVbpDCR43PuKaSMWMEWUrveDWFqDfRFk7Fq49ShHqRJz95Ye2wVM3ngNlMKphvXAFZNiwiKSvSRtlj8bxv1co7A6SSEVsq3yNTMnrEvjuNi6EzwBqGdLSSUfI26tJPlJ+0Q550mSzlcLmEYxjdusuPLnzfGJV53T7RyS84zn+9MyLSqTajKBZ4YkhOLTaAOP/t7FUNPyMwiBoC4b6Ofh3Ittr/0Q7CLUK/GIKQADGJ3SbKD5OjIRyU+to50AAU548OOET16ETwetxLF0RDgCo2woTuLvS9cDnIYy/7/Y4W6JlmqvtSc2fv5SWZziSfgi5ZMtaKnQRSXe3nfO7Cl6gdUyQH8oet3L7V+xo3E2ymCVuZUKqeay6qpUJ01ALJtsr+YXPHgI7xSNzS5u9vw0cjUoqcoUEWewFL89EjBLr4T1psS7t1nCRn56aH9a07Jm9dPETL4Cll7/AE4woRbeNjI4wxRemu1K8B5bW1s3jBKfUFq/caTo8fWCvvtBCzlUYCGMkwaHMz1mlPMejAK3cDd8YKgF43fzhef+k86fPp460r55AOK7mqIFtqOWXymbFrRqcG+zqkHFSJRr6tCrYrTNicDve91WL64hIQ7zrmppDrT507+qJPpbxDUYGTrZedo1R05GR5vfx7Eiax2yTB5Yo6vNutaoG3QI/V+ZBA++BIFcGw0Cfiunto/Q0A==
{{- else }}
# TODO dev secret
{{- end }}
13 changes: 11 additions & 2 deletions charts/drinkn/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Default values for drinkn.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
image:
tag: "sha-f2bcc8e"

replicas: "2"

fqdn: pils.oscarr.nl

pr:
enabled: false
number: 9999

0 comments on commit 4e06394

Please sign in to comment.