From 988382bf8cbba028226a69237c5b4bf9905c0084 Mon Sep 17 00:00:00 2001 From: DaanSelen <135789+daanselen@noreply.gitea.com> Date: Thu, 9 Apr 2026 09:29:43 +0000 Subject: [PATCH] feat: add ability to remove the .runner file within the helm chart (#126) fix: https://gitea.com/gitea/helm-actions/issues/73 --------- Co-authored-by: DaanSelen Reviewed-on: https://gitea.com/gitea/helm-actions/pulls/126 --- README.md | 3 ++- templates/statefulset.yaml | 17 +++++++++++++++++ values.yaml | 5 ++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3fc0689..070c840 100644 --- a/README.md +++ b/README.md @@ -80,8 +80,9 @@ If `.Values.statefulset.dind.rootless: true` is set, then the following will be | `statefulset.actRunner.pullPolicy` | The Gitea act runner pullPolicy | `IfNotPresent` | | `statefulset.actRunner.fullOverride` | Completely overrides the image registry, path/image, tag and digest. | `""` | | `statefulset.actRunner.extraVolumeMounts` | Allows mounting extra volumes in the act runner container | `[]` | -| `statefulset.actRunner.config` | Act runner custom configuration. See [Act Runner documentation](https://docs.gitea.com/usage/actions/act-runner#configuration) for details. | `Too complex. See values.yaml` | | `statefulset.actRunner.extraEnvs` | Allows adding custom environment variables | `[]` | +| `statefulset.actRunner.flushCache` | whether to clear the .runner (cache) file by creating an extra init container, can slightly increase boot-up time | `false` | +| `statefulset.actRunner.config` | Act runner custom configuration. See [Act Runner documentation](https://docs.gitea.com/usage/actions/act-runner#configuration) for details. | `Too complex. See values.yaml` | | `statefulset.dind.rootless` | a simple flag to let helm know we are dealing with a rootless dind container | `false` | | `statefulset.dind.uid` | a field to set the running user id for the rootless dind container, so it knows where to look for the socket | `""` | | `statefulset.dind.registry` | image registry, e.g. gcr.io,docker.io | `docker.io` | diff --git a/templates/statefulset.yaml b/templates/statefulset.yaml index f2900e8..4f98f2c 100644 --- a/templates/statefulset.yaml +++ b/templates/statefulset.yaml @@ -49,6 +49,23 @@ spec: {{- if .Values.preExtraInitContainers }} {{- toYaml .Values.preExtraInitContainers | nindent 8 }} {{- end }} + {{- if .Values.statefulset.actRunner.flushCache }} + - name: cache-flusher + image: "{{ include "gitea.actions.init.image" . }}" + command: + - sh + - -c + - | + if [[ -f /data/.runner ]]; then + echo "Removing cache at /data/.runner" + rm -v /data/.runner + else + echo "No .runner file to remove" + fi + volumeMounts: + - mountPath: /data + name: data-act-runner + {{- end }} - name: init-gitea image: "{{ include "gitea.actions.init.image" . }}" command: diff --git a/values.yaml b/values.yaml index 1dafba6..ef53d5a 100644 --- a/values.yaml +++ b/values.yaml @@ -26,8 +26,9 @@ ## @param statefulset.actRunner.pullPolicy The Gitea act runner pullPolicy ## @param statefulset.actRunner.fullOverride Completely overrides the image registry, path/image, tag and digest. ## @param statefulset.actRunner.extraVolumeMounts Allows mounting extra volumes in the act runner container -## @param statefulset.actRunner.config [default: Too complex. See values.yaml] Act runner custom configuration. See [Act Runner documentation](https://docs.gitea.com/usage/actions/act-runner#configuration) for details. ## @param statefulset.actRunner.extraEnvs Allows adding custom environment variables +## @param statefulset.actRunner.flushCache whether to clear the .runner (cache) file by creating an extra init container, can slightly increase boot-up time +## @param statefulset.actRunner.config [default: Too complex. See values.yaml] Act runner custom configuration. See [Act Runner documentation](https://docs.gitea.com/usage/actions/act-runner#configuration) for details. # ## @param statefulset.dind.rootless [default: false] a simple flag to let helm know we are dealing with a rootless dind container ## @param statefulset.dind.uid a field to set the running user id for the rootless dind container, so it knows where to look for the socket @@ -82,6 +83,8 @@ statefulset: # fieldRef: # fieldPath: metadata.name + # See full details: https://gitea.com/gitea/helm-actions/issues/73 + flushCache: false # See full example here: https://gitea.com/gitea/act_runner/src/branch/main/internal/pkg/config/config.example.yaml config: | log: