diff --git a/.github/workflows/helm-chart-dependency.yml b/.github/workflows/helm-chart-dependency.yml new file mode 100644 index 0000000..4eda8e4 --- /dev/null +++ b/.github/workflows/helm-chart-dependency.yml @@ -0,0 +1,66 @@ +name: Check for Helm Chart Updates + +on: + schedule: + - cron: '0 0 * * *' + pull_request: + types: [ opened, edited, reopened, synchronize ] + + +jobs: + check-helm-chart-update: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.2 + with: + aws-region: eu-west-2 + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + role-session-name: GitHubWorkflow + - name: Setup Kubectl and Helm + uses: yokawasa/action-setup-kube-tools@v0.11.1 + with: + setup-tools: | + kubectl + helm + kubectl: '1.25.6' + helm: '3.14.3' + - name: Update Kubeconfig + run: | + make get-kubeconfig + + - name: Add Prometheous Community Repo and Update + run: | + helm repo add prometheus-community https://prometheus-community.github.io/helm-charts + helm repo update + + - name: Get Latest Helm Chart Version + id: latest_version + run: | + echo "::set-output name=version::$(helm search repo prometheus-community/kube-prometheus-stack -o json | jq -r '.[0].version')" + + - name: Check Current Version + id: current_version + run: | + current_version=$(grep 'kube-prometheus-stack:' path/to/your/helm/dependency/file | awk '{print $2}') + echo "::set-output name=current_version::$current_version" + + - name: Compare Versions and Update + run: | + if [ "${{ steps.latest_version.outputs.version }}" != "${{ steps.current_version.outputs.current_version }}" ]; then + echo "Updating to version ${{ steps.latest_version.outputs.version }}" + sed -i 's/\(helm upgrade --install kube-prometheus-stack prometheus-community\/kube-prometheus-stack \--version \)[^ ]*/\1${{ steps.latest_version.outputs.version }}/' scripts/deploy.sh + git config --global user.email "actions@github.com" + git config --global user.email "actions@github.com" + git config --global user.name "GitHub Actions" + git checkout -b update-helm-chart + git add scripts/deploy.sh + git commit -m "Update kube-prometheus-stack to version ${{ steps.latest_version.outputs.version }}" + git push origin update-helm-chart + gh pr create --title "Update kube-prometheus-stack to version ${{ steps.latest_version.outputs.version }}" --body "This PR updates the kube-prometheus-stack Helm chart to the latest version." + else + echo "No updates available." + fi