forked from beehivewarrior/bump_helm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
127 lines (112 loc) · 4.94 KB
/
action.yaml
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: 'Bump Chart Version'
description: Avoids Chart Releaser errors when forgetting to increment the chart version. Works with Chart Releaser {name}-{semver} tags to bump Helm Chart Version if there are chart changes in current branch and release already exists.
author: beehivewarrior
branding:
icon: anchor
color: blue
inputs:
chart_dir:
description: 'Chart to be bumped'
required: true
bump_strategy:
description: '"patch", "minor", or "major": semver magnitude to bump'
required: false
default: patch
outputs:
version_bumped:
description: Boolean indicating that the version was incremented.
value: ${{ steps.bump-chart-version.outputs.version_bumped }}
runs:
using: composite
steps:
- uses: actions/checkout@v4
with:
# we need all history to reliably find the latest release tag for each chart
fetch-depth: '0'
fetch-tags: 'true'
- name: Read Helm Chart Before Bump
id: readChartBefore
uses: netfoundry/helm-metadata-action@main
with:
path: ${{ inputs.chart_dir }}
- name: Print Helm Chart Version
run: >
echo 'INFO: chart name: "${{ steps.readChartBefore.outputs.name }}"'
echo 'INFO: chart version before bump: "${{ steps.readChartBefore.outputs.version }}"'
shell: bash
- name: Fetch latest release version of this chart
id: latest-release
uses: netfoundry/latest-release-action@main
with:
tag-prefix: ${{ format ('{0}-', steps.readChartBefore.outputs.name) }}
- name: Check if Chart Changed Since Latest Release
uses: tj-actions/changed-files@v44
id: chartChanged
with:
files: |
${{ inputs.chart_dir }}
base_sha: ${{ steps.latest-release.outputs.commit-sha }}
- run: >
echo 'INFO: check changes result: "${{ steps.chartChanged.outputs.any_modified }}"'
shell: bash
- name: Check if a Release Tag Exists
uses: mukunku/[email protected]
if: steps.chartChanged.outputs.any_modified == 'true'
id: checkTag
with:
tag: ${{ format ('{0}-{1}', steps.readChartBefore.outputs.name, steps.readChartBefore.outputs.version) }}
- name: Print Release Tag Check Result
run: >
echo 'INFO: check tag exists result: "${{ steps.checkTag.outputs.exists }}"'
shell: bash
- name: Bump the Helm Chart Version
if: steps.chartChanged.outputs.any_modified == 'true' && steps.checkTag.outputs.exists == 'true'
uses: netfoundry/helm-chart-pybump-action@main
with:
chart-path: ${{ inputs.chart_dir }}
app_version: false # only bump chart version, not appVersion
level: ${{ inputs.bump_strategy }}
- name: Read Helm Chart After Bump
if: steps.chartChanged.outputs.any_modified == 'true' && steps.checkTag.outputs.exists == 'true'
id: readChartAfter
uses: netfoundry/helm-metadata-action@main
with:
path: ${{ inputs.chart_dir }}
- name: Print Helm Chart Version
if: steps.chartChanged.outputs.any_modified == 'true' && steps.checkTag.outputs.exists == 'true'
run: >
echo 'INFO: chart name: "${{ steps.readChartAfter.outputs.name }}"'
echo 'INFO: chart version after bump: "${{ steps.readChartAfter.outputs.version }}"'
shell: bash
- name: Regenerate Helm Docs if Version Bumped
if: steps.chartChanged.outputs.any_modified == 'true' && steps.checkTag.outputs.exists == 'true'
uses: netfoundry/helm-docs-action@main
with:
# recursively generate README.md for all charts in comma-sep list of
# parent dirs
search-roots: ${{ inputs.chart_dir }}
git-push: "false"
- name: Compose Bump Message if Changed
id: bumpMessage
if: steps.chartChanged.outputs.any_modified == 'true' && steps.checkTag.outputs.exists == 'true'
run: |
echo "bump_message<<OUTER_EOF" >> $GITHUB_OUTPUT
cat <<'INNER_EOF' >> $GITHUB_OUTPUT
Bumped "${{ steps.readChartAfter.outputs.name }}" version from "${{ steps.readChartBefore.outputs.version }}" to "${{ steps.readChartAfter.outputs.version }}".
Changes committed by ${{ github.actor }} in commit: ${{ github.event.after }} altered the Helm Chart.
I updated the "version" in Chart.yaml file using the "${{ inputs.bump_strategy }}" strategy.
Signed-off-by: github-bot[bot] <[email protected]>
INNER_EOF
echo "OUTER_EOF" >> $GITHUB_OUTPUT
shell: bash
- name: Commit Bump if Changed
if: steps.chartChanged.outputs.any_modified == 'true' && steps.checkTag.outputs.exists == 'true'
uses: netfoundry/git-push-action@main
with:
email: ${{ github.actor }}@github.com
name: ${{ github.actor }}
message: |
${{ steps.bumpMessage.outputs.bump_message }}
branch: ${{ github.head_ref || github.ref_name }}
# use the proposed changes in case of conflict during rebase on the base branch
strategy: theirs