Check for new chart release #421
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: '' | |
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 }} | |
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=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 | |
# Directly check if the feature branch exists and has the same changes in the remote repository | |
if git ls-remote --heads origin update-release > /dev/null; then | |
if git diff --no-ext-diff --quiet origin/update-release -- helm-charts; then | |
echo "PR_NEEDED=0" >> "$GITHUB_OUTPUT" | |
fi | |
fi | |
- 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@v7 | |
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 |