-
Notifications
You must be signed in to change notification settings - Fork 2
58 lines (53 loc) · 1.96 KB
/
bump-chart.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
name: Bump Chart Version
on:
workflow_dispatch:
inputs:
chart-version:
description: 'The new chart version'
required: true
type: string
workflow_call:
inputs:
chart-version:
description: 'The new chart version'
required: true
type: string
secrets:
token:
description: 'The github token to use to create the PR'
required: true
jobs:
update-app-version:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Update version
uses: actions/github-script@v7
env:
NEW_VERSION: ${{ inputs.chart-version }}
with:
script: |
const fs = require('fs');
const file = fs.readFileSync('variables.tf', 'utf8');
const lines = file.split('\n');
const chartVersionLine = lines.findIndex(line => line.includes('chart_version'));
const versionLine = lines.findIndex((line, i) => line.includes('default') && i > chartVersionLine);
const oldVersion = lines[versionLine].match(/"([^"]+)"/)[1];
const newVersion = process.env.NEW_VERSION;
lines[versionLine] = lines[versionLine].replace(oldVersion, newVersion);
fs.writeFileSync('variables.tf', lines.join('\n'));
console.log(`updated version from ${oldVersion} to ${newVersion}`);
- name: Generate version bump commit
run: |
git config user.name ${{ github.actor }}
git config user.email '${{ github.actor }}@users.noreply.github.com'
git commit -a -m "bump chart version to '${{ inputs.chart-version }}'"
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v4
with:
token: ${{ github.token }}
title: '[bump] chart - ${{ inputs.chart-version }}'
branch: bump/chart_${{ inputs.chart-version }}
delete-branch: true
labels: auto_version_bump