forked from signalfx/splunk-otel-collector-chart
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (95 loc) · 4.4 KB
/
release_drafter.yaml
File metadata and controls
105 lines (95 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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'
permissions:
contents: write
pull-requests: write
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install chloggen
run: make install-chloggen
- 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 }}
run: |
pip install pre-commit==4.5.1
pre-commit run --all-files || true
env:
SKIP: actionlint,render,go-fmt,go-lint,go-mod-tidy
- 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: ./.github/actions/create-pr
with:
branch: update-release
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 }}
author-name: ${{ github.event_name == 'schedule' && 'github-actions[bot]' || github.actor }}
author-email: ${{ github.event_name == 'schedule' && '41898282+github-actions[bot]@users.noreply.github.com' || format('{1}+{0}@users.noreply.github.com', github.actor, github.actor_id) }}