diff --git a/.github/workflows/updatecli.yaml b/.github/workflows/updatecli.yaml new file mode 100644 index 0000000..eda466a --- /dev/null +++ b/.github/workflows/updatecli.yaml @@ -0,0 +1,48 @@ +--- +name: Updatecli + +on: + # Trigger Updatecli if a new commit land on the main branch + push: + branches: [ main ] + # Trigger Updatecli if a pullrequest is open targeting the main branch. + # This is useful to test Updatecli manifest change + pull_request: + branches: [ main ] + # Manually trigger Updatecli via GitHub UI + workflow_dispatch: + # Trigger Updatecli once day by a cronjob + schedule: + # * is a special character in YAML, so you have to quote this string + # Run once a day + - cron: '0 0 * * *' + +permissions: + contents: "write" + pull-requests: "write" + +jobs: + updatecli: + runs-on: "ubuntu-latest" + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Updatecli in the runner + uses: updatecli/updatecli-action@v2 + + - uses: azure/setup-kubectl@v3 + id: install + + - uses: azure/setup-helm@v4.2.0 + id: install + + - name: Run Updatecli in Dry Run mode + run: "updatecli diff --config ./updatecli/updatecli.d --values updatecli/values.yaml" + env: + UPDATECLI_GITHUB_TOKEN: "${{ secrets.UPDATECLI_GITHUB_TOKEN }}" + + - name: Run Updatecli in apply mode + run: "updatecli apply --config ./updatecli/updatecli.d --values updatecli/values.yaml" + env: + UPDATECLI_GITHUB_TOKEN: "${{ secrets.UPDATECLI_GITHUB_TOKEN }}" diff --git a/grafana/operator-values.yaml b/grafana/operator-values.yaml index 5642fcb..4e7f7bf 100644 --- a/grafana/operator-values.yaml +++ b/grafana/operator-values.yaml @@ -1,5 +1,5 @@ -#image: -# tag: v0.34.1 +image: + tag: v0.41.1 resources: requests: memory: 30Mi diff --git a/updatecli/updatecli.d/agent.yaml b/updatecli/updatecli.d/agent.yaml new file mode 100644 index 0000000..4076d7c --- /dev/null +++ b/updatecli/updatecli.d/agent.yaml @@ -0,0 +1,33 @@ +sources: + lastGithubRelease: + kind: githubrelease + spec: + owner: 'grafana' + repository: 'agent' + token: '{{ requiredEnv "UPDATECLI_GITHUB_TOKEN" }}' + versionfilter: + kind: latest + +targets: + agent_image: + name: Bump Agent image version + kind: hcl + spec: + file: 'locals.tf' + path: 'locals.agent_version' + transformers: + - trimprefix: "v" + operator_image: + name: Bump Operator image version + kind: yaml + spec: + file: 'grafana/operator-values.yaml' + key: '$.image.tag' + module_version: + name: Bump Operator module version + kind: hcl + spec: + file: 'locals.tf' + path: 'locals.version' + transformers: + - trimprefix: "v" diff --git a/updatecli/updatecli.d/grafana.yaml b/updatecli/updatecli.d/grafana.yaml new file mode 100644 index 0000000..7767672 --- /dev/null +++ b/updatecli/updatecli.d/grafana.yaml @@ -0,0 +1,26 @@ +sources: + lastRelease: + kind: helmchart + spec: + url: 'https://grafana.github.io/helm-charts' + name: 'grafana-agent-operator' + +targets: + chart: + name: Bump Chart Version + kind: yaml + spec: + file: 'grafana/kustomization.yaml' + key: '$.helmCharts[0].version' + transformers: + - addprefix: "'" + - addsuffix: "'" + kubectl: + name: run kubectl when manifest.yaml changed + kind: shell + dependson: + - chart + dependsonchange: true + disablesourceinput: true + spec: + command: "kubectl kustomize . -o grafana-agent.yaml --enable-helm" diff --git a/updatecli/updatecli.d/ksm.yaml b/updatecli/updatecli.d/ksm.yaml new file mode 100644 index 0000000..6776737 --- /dev/null +++ b/updatecli/updatecli.d/ksm.yaml @@ -0,0 +1,26 @@ +sources: + lastRelease: + kind: helmchart + spec: + url: 'https://prometheus-community.github.io/helm-charts' + name: 'kube-state-metrics' + +targets: + chart: + name: Bump Chart Version + kind: yaml + spec: + file: 'ksm/kustomization.yaml' + key: '$.helmCharts[0].version' + transformers: + - addprefix: "'" + - addsuffix: "'" + kubectl: + name: run kubectl when manifest.yaml changed + kind: shell + dependson: + - chart + dependsonchange: true + disablesourceinput: true + spec: + command: "kubectl kustomize . -o grafana-agent.yaml --enable-helm" diff --git a/updatecli/values.yaml b/updatecli/values.yaml new file mode 100644 index 0000000..7960d1d --- /dev/null +++ b/updatecli/values.yaml @@ -0,0 +1,5 @@ +github: + user: "UpdateCLI" + email: "updatecli@opzkit.io" + username: "github-actions" + token: "UPDATECLI_GITHUB_TOKEN"