Skip to content

Check for new chart release #1510

Check for new chart release

Check for new chart release #1510

name: Check for new chart release
# Description:
# This workflow prepares a new release of the helm chart by updating chart and app versions as well as creating a PR.
# A release PR will be created in these cases.
# - When a user kicks offs this workflow manually. A user can specify the CHART_VERSION and APP_VERSION used for the new release.
# - When the cron schedule kicks off the job and there is a version difference for the collector application, then a chart release draft PR will be created with the version automatically incremented appropriately.
on:
schedule:
# Run every 12 hours at 55 minutes past the hour.
- cron: "55 */12 * * *"
workflow_dispatch:
inputs:
CHART_VERSION:
description: 'Optionally overrides the chart version in Chart.yaml.'
required: false
default: ''
APP_VERSION:
description: 'Optionally overrides the app version in Chart.yaml.'
required: false
default: ''
OVERWRITE_EXISTING_PR:
description: 'Allow updating an existing update-release PR if changes differ.'
required: false
default: 'false'
type: choice
options:
- 'false'
- 'true'
DEBUG:
description: 'Enable debug mode for the script.'
required: false
default: 'false'
jobs:
prepare_release:
runs-on: ubuntu-latest
env:
CHART_VERSION: ${{ github.event.inputs.CHART_VERSION }}
APP_VERSION: ${{ github.event.inputs.APP_VERSION }}
OVERWRITE_EXISTING_PR: ${{ github.event.inputs.OVERWRITE_EXISTING_PR }}
DEBUG: ${{ github.event.inputs.DEBUG }}
steps:
- uses: actions/checkout@v6
- name: Install tools
run: make install-tools
- name: Prepare Release
id: prepare_release
run: |
make prepare-release CHART_VERSION=$CHART_VERSION APP_VERSION=$APP_VERSION CREATE_BRANCH=false DEBUG=$DEBUG
- name: Check if PR is already open
id: check_if_pr_open
run: |
echo "PR_NEEDED=1" >> "$GITHUB_OUTPUT"
git fetch origin
# Check if update-release branch exists
if [ -n "$(git ls-remote --heads origin update-release)" ]; then
if [ "$OVERWRITE_EXISTING_PR" = "true" ]; then
# Overwrite mode: Only skip if changes are identical
echo "OVERWRITE_EXISTING_PR is enabled - checking for changes"
if git diff --no-ext-diff --quiet origin/update-release -- helm-charts; then
echo "PR_NEEDED=0" >> "$GITHUB_OUTPUT"
echo "Skipping PR creation - no changes detected"
else
echo "Changes detected - will update existing PR"
fi
else
# Default mode: Skip if branch exists
echo "PR_NEEDED=0" >> "$GITHUB_OUTPUT"
echo "Skipping PR creation - update-release branch already exists"
echo "Use OVERWRITE_EXISTING_PR=true to allow updating if changes differ"
fi
fi
- name: Run pre-commit to fix formatting
if: ${{ steps.prepare_release.outputs.NEED_UPDATE == 1 && steps.check_if_pr_open.outputs.PR_NEEDED == 1 }}
uses: ./.github/actions/run-precommit
- name: Open PR for Version Update
id: open_pr
if: ${{ steps.prepare_release.outputs.NEED_UPDATE == 1 && steps.check_if_pr_open.outputs.PR_NEEDED == 1 }}
uses: peter-evans/create-pull-request@v8
with:
commit-message: Prepare release v${{ steps.prepare_release.outputs.LATEST_CHART_VERSION }}
title: Prepare release v${{ steps.prepare_release.outputs.LATEST_CHART_VERSION }}
body: |
Description
- Release Helm chart version ${{ steps.prepare_release.outputs.LATEST_CHART_VERSION }}
- Includes collector version ${{ steps.prepare_release.outputs.LATEST_APP_VERSION }}
branch: update-release
base: main
delete-branch: true
author: ${{ github.event_name == 'schedule' && 'github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>' || format('{0} <{1}+{0}@users.noreply.github.com>', github.actor, github.actor_id) }}