Skip to content

Commit

Permalink
Add cozy update workflow (#5)
Browse files Browse the repository at this point in the history
* Add cozy update workflow

* Pin cozy image tag

* Bump cozy chart version

* Increase cozy's memory limit
  • Loading branch information
Pyrofab authored Jun 4, 2024
1 parent 31ac3db commit 86e7222
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 21 deletions.
14 changes: 14 additions & 0 deletions .github/actions/update-app-version/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM alpine:3.10

WORKDIR /github/workspace

ARG YQ_VERSION=v4.44.1
ARG YQ_BINARY=yq_linux_amd64

RUN apk add --no-cache wget \
&& wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_BINARY} -O /usr/bin/yq \
&& chmod +x /usr/bin/yq

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
15 changes: 15 additions & 0 deletions .github/actions/update-app-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Update App Version'
description: "Update a Helm chart's application version"
inputs:
path:
description: 'Path to the chart to update'
required: true
tag:
description: 'New tag for the docker image'
required: true
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.path }}
- ${{ inputs.tag }}
10 changes: 10 additions & 0 deletions .github/actions/update-app-version/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

values_file="$1/values.yaml"
chart_file="$1/Chart.yaml"
yq eval ".image.tag = \"$2\"" -i "$values_file"
yq eval ".appVersion = \"$2\"" -i "$chart_file"

current_version=$(yq eval '.version' "$chart_file")
new_version=$(echo "$current_version" | awk -F. '{OFS="."; $3=$3+1; print}')
yq eval ".version = \"$new_version\"" -i "$chart_file"
11 changes: 5 additions & 6 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ jobs:
tag=$(cut -c 1-7 <<< $GITHUB_SHA)
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: Build images
run: |
docker build ./images/postgresql-s3-backup/ -t ghcr.io/quiltmc/postgresql-s3-backup:latest
docker tag ghcr.io/quiltmc/postgresql-s3-backup:latest ghcr.io/quiltmc/postgresql-s3-backup:${{ steps.sha_tag.outputs.tag }}
docker build ./images/mongodb-s3-backup/ -t ghcr.io/quiltmc/mongodb-s3-backup:latest
docker tag ghcr.io/quiltmc/mongodb-s3-backup:latest ghcr.io/quiltmc/mongodb-s3-backup:${{ steps.sha_tag.outputs.tag }}
- name: Build postgresql-s3-backup image
run: docker build ./images/postgresql-s3-backup/ -t ghcr.io/quiltmc/postgresql-s3-backup:latest -t ghcr.io/quiltmc/postgresql-s3-backup:${{ steps.sha_tag.outputs.tag }}

- name: Build mongodb-s3-backup image
run: docker build ./images/mongodb-s3-backup/ -t ghcr.io/quiltmc/mongodb-s3-backup:latest -t ghcr.io/quiltmc/mongodb-s3-backup:${{ steps.sha_tag.outputs.tag }}

- name: Login to Github Container Registry
if: github.ref == 'refs/heads/main'
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/cozy-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Update Cozy version

on:
repository_dispatch:
types: [cozy_update]

concurrency: build-${{ github.sha }}

jobs:
update:
if: ${{ github.event.client_payload.tag }}
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Update chart
uses: ./.github/actions/update-app-version
with:
path: charts/cozy
tag: ${{ github.event.client_payload.tag }}

- name: Commit and push
run: |
git config --global user.name "Cozy's Valet"
git config --global user.email '[email protected]'
git commit -am "Update cozy version"
git push
2 changes: 1 addition & 1 deletion charts/cozy/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: quilt-cozy
# 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.1.5
version: 1.1.6
# This is the version number of the application being deployed (purely informational).
appVersion: '1'
description: helm chart to deploy the Quilt Cozy Discord bot
Expand Down
16 changes: 8 additions & 8 deletions charts/cozy/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ spec:
type: RuntimeDefault
containers:
- name: cozy-quilt
image: {{ .Values.image }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
imagePullPolicy: Always
imagePullPolicy: IfNotPresent
env:
- name: MODE
value: quilt
Expand All @@ -50,13 +50,13 @@ spec:
resources:
{{ toYaml .Values.resources | nindent 12 }}
- name: cozy-collab
image: {{ .Values.image }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
imagePullPolicy: Always
imagePullPolicy: IfNotPresent
env:
- name: MODE
value: collab
Expand All @@ -68,13 +68,13 @@ spec:
resources:
{{ toYaml .Values.resources | nindent 12 }}
- name: cozy-showcase
image: {{ .Values.image }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
imagePullPolicy: Always
imagePullPolicy: IfNotPresent
env:
- name: MODE
value: showcase
Expand All @@ -86,13 +86,13 @@ spec:
resources:
{{ toYaml .Values.resources | nindent 12 }}
- name: cozy-dev
image: {{ .Values.image }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
imagePullPolicy: Always
imagePullPolicy: IfNotPresent
env:
- name: MODE
value: dev
Expand Down
10 changes: 4 additions & 6 deletions charts/cozy/values.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
image: ghcr.io/quiltmc/cozy-discord:latest
image:
repository: 'ghcr.io/quiltmc/cozy-discord'
tag: 'd5b639dd8cf0869c6f9707b5fa2b2f5153dfa74f'
namespace: quilt
replicaCount: 1

messageLogs: '839495849116958780,839496251463958548'
releaseChannels: '832351145073573889,832351173640978472'
statusChannel: '1009020306280681532'

# cf. https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
resources:
limits:
cpu: 400m
memory: 924Mi
memory: 1200Mi
requests:
cpu: 400m
memory: 724Mi

mongodb:
auth:
rootPassword: cozy
Expand All @@ -24,7 +23,6 @@ mongodb:
- cozy
databases:
- cozy

mongodb-s3-backup:
database:
password: cozy

0 comments on commit 86e7222

Please sign in to comment.