Skip to content

Helm Repo Update

Helm Repo Update #1

name: Helm Repo Update
on:
schedule:
# 06:00 UTC every Monday.
- cron: '0 6 * * 1'
workflow_dispatch: {}
permissions:
contents: write
pull-requests: write
# This will only allow a single markdownlint action to run per PR.
# Any github action running on the older commits will be aborted.
concurrency:
group: helm-repo-update
cancel-in-progress: false
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7.0.0
with:
# Don't set this to 1, the script script does
# git switch -c "$GIT_BRANCH_NAME" --track origin/master - this
# requires origin/master to exist as a ref, so actions/checkout
# must not be a shallow-default-branch-only checkout in a way
# that hides origin/master
fetch-depth: 0
- name: Configure git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@obmondo.com"
- name: Setup Helm
uses: azure/setup-helm@v5
with:
version: 'v3.21.3'
- name: Run helm-repo-update
id: update
env:
FIXED_BRANCH: automation/helm-repo-update
run: |
./bin/manage-helm-chart.sh --update-all
# The script creates and switches to a new, randomly-named
# branch itself (Helm_Update_<date>_<random>) and commits
# directly to it if there were any changes. We don't modify
# that behavior; instead we rename the branch locally to a
# fixed name so repeated runs update the same PR instead of
# opening a new one every time.
current_branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$current_branch" = "master" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No changes: script stayed on master, nothing to update."
else
git branch -M "$current_branch" "$FIXED_BRANCH"
echo "branch=${FIXED_BRANCH}" >> "$GITHUB_OUTPUT"
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Verify helm charts template cleanly
if: steps.update.outputs.changed == 'true'
run: |
./scripts/verify-helm-charts.sh
- name: Push update branch
if: steps.update.outputs.changed == 'true'
run: git push origin "${{ steps.update.outputs.branch }}" --force
- name: Create or update pull request
if: steps.update.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
BRANCH: ${{ steps.update.outputs.branch }}
run: |
existing_pr="$(gh pr list --head "$BRANCH" --base master --state open --json number --jq '.[0].number // empty')"
if [ -n "$existing_pr" ]; then
echo "Updating existing PR #${existing_pr}"
gh pr edit "$existing_pr" \
--title "chore(helm): update helm chart dependencies" \
--body "Automated Helm chart dependency update, generated by the \`Helm Repo Update\` workflow running \`bin/manage-helm-chart.sh --update-all\`."
else
echo "Opening new PR for branch ${BRANCH}"
gh pr create \
--head "$BRANCH" \
--base master \
--title "chore(helm): update helm chart dependencies" \
--body "Automated Helm chart dependency update, generated by the \`Helm Repo Update\` workflow running \`bin/manage-helm-chart.sh --update-all\`."
fi