diff --git a/helm-deploy/action.yml b/helm-deploy/action.yml index 6beb1cb..88b0ff6 100644 --- a/helm-deploy/action.yml +++ b/helm-deploy/action.yml @@ -26,18 +26,24 @@ inputs: namespace: description: "The namespace in which to deploy the Helm chart and application" required: true - values-file: - description: "Path to the Helm values file" - required: true image-tag: description: "Tag of the container image" default: "latest" - timeout: - description: "Timeout for the Helm command" - default: "5m" working-directory: description: "The working directory" default: "." + values-file: + description: "Path to the Helm values file" + required: true + grafana-dashboards-folder: + description: "Folder containing Grafana dashboards" + default: "dashboards" + grafana-alerts-folder: + description: "Folder containing Grafana alerts" + default: "alerts" + timeout: + description: "Timeout for the Helm command" + default: "5m" runs: using: "composite" @@ -69,6 +75,35 @@ runs: yq -i '.appVersion = "${{ github.sha }}" | .appVersion style="double"' \ ${{ inputs.helm-package }}/Chart.yaml + - name: Collect Grafana dashboards and alerts + id: grafana-files + shell: bash + working-directory: ${{ inputs.working-directory }} + run: | + SET_FILE_ARGS="" + + if [[ -d "${{ inputs.grafana-dashboards-folder }}" ]] && [[ "$(ls -A "${{ inputs.grafana-dashboards-folder }}")" ]]; then + i=0 + for f in "${{ inputs.grafana-dashboards-folder }}"/*; do + if [[ -f "$f" ]]; then + SET_FILE_ARGS+=" --set-file grafana.dashboards[$i]=$f" + ((i++)) + fi + done + fi + + if [[ -d "${{ inputs.grafana-alerts-folder }}" ]] && [[ "$(ls -A "${{ inputs.grafana-alerts-folder }}")" ]]; then + i=0 + for f in "${{ inputs.grafana-alerts-folder }}"/*; do + if [[ -f "$f" ]]; then + SET_FILE_ARGS+=" --set-file grafana.alerts[$i]=$f" + ((i++)) + fi + done + fi + + echo "set-file-args=$SET_FILE_ARGS" >> $GITHUB_OUTPUT + - name: Deploy Helm chart shell: bash working-directory: ${{ inputs.working-directory }} @@ -76,8 +111,9 @@ runs: HELM_DRIVER: configmaps run: | helm upgrade --wait --install ${{ inputs.release-name }} ./${{ inputs.helm-package }} \ - --namespace ${{ inputs.namespace }} \ --history-max 10 \ - --values ${{ inputs.values-file }} \ --atomic --timeout ${{ inputs.timeout }} \ - --set image.tag=${{ inputs.image-tag }} + --set image.tag=${{ inputs.image-tag }} \ + --namespace ${{ inputs.namespace }} \ + --values ${{ inputs.values-file }} \ + ${{ steps.grafana-files.outputs.set-file-args }}