Skip to content

Check for new chart release #2

Check for new chart release

Check for new chart release #2

name: Prepare New Helm 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 major or minor version different for the APP_VERSION. The CHART_VERSION will be automatically incremented appropriately.
on:
schedule:
# Run every 12 hours at 55 minutes past the hour.
- cron: "55 */12 * * *"
workflow_dispatch:
inputs:
CREATE_BRANCH:
description: 'Whether to create a remote branch for the release. Defaults to false since peter-evans/create-pull-request steps will handle branch creation.'
required: false
default: 'false'
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: ''
DEBUG:
description: 'Enable debug mode for the script.'
required: false
default: 'false'
jobs:
prepare_release:
runs-on: ubuntu-latest
env:
CREATE_BRANCH: ${{ github.event.inputs.CREATE_BRANCH }}
CHART_VERSION: ${{ github.event.inputs.CHART_VERSION }}
APP_VERSION: ${{ github.event.inputs.APP_VERSION }}
DEBUG: ${{ github.event.inputs.DEBUG }}
steps:
- uses: actions/checkout@v4
- 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=$CREATE_BRANCH DEBUG=$DEBUG
- name: Check if PR is already open
id: check_if_pr_open
run: |
DIFF=1
git fetch origin
((git show-ref --verify --quiet refs/heads/update-release) || (git diff --no-ext-diff --quiet main..update-release -- helm-charts)) && DIFF=0
echo "PR_NEEDED=$DIFF" >> "$GITHUB_OUTPUT"
- 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@v6
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: Updating Helm chart from version ${{ steps.prepare_release.outputs.CURRENT_CHART_VERSION }} to ${{ steps.prepare_release.outputs.LATEST_CHART_VERSION }} and App version from ${{ steps.prepare_release.outputs.CURRENT_APP_VERSION }} to ${{ steps.prepare_release.outputs.LATEST_APP_VERSION }}
branch: "update-release" # Same branch name for all PRs
base: main
delete-branch: true