-
Notifications
You must be signed in to change notification settings - Fork 1
52 lines (50 loc) · 2.09 KB
/
create-chart-update-pr.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
name: "Create chart update Pull Request"
on:
workflow_dispatch:
inputs:
app-version:
description: app version (e.g. 0.1.0)
type: string
chart-version:
description: chart version (e.g. 0.1.0)
type: string
jobs:
create-chart-update-pr:
runs-on: "ubuntu-latest"
steps:
- name: "Validate input"
run: |
# The exit code will be 1 if the pattern is not found by grep.
echo ${{ inputs.app-version }} | grep -E "^[0-9]+.[0-9]+.[0-9]+$"
echo ${{ inputs.chart-version }} | grep -E "^[0-9]+.[0-9]+.[0-9]+$"
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
# ref. https://github.com/orgs/community/discussions/26560#discussioncomment-3252340
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: "Create a branch"
run: |
git switch main
git pull
git switch -c bump-chart-${{ inputs.chart-version }}
- name: "Update files"
run: |
sed -r -i "s/version: [[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+/version: ${{ inputs.chart-version }}/g" charts/pie/Chart.yaml
sed -r -i "s/appVersion: [[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+/appVersion: ${{ inputs.app-version }}/g" charts/pie/Chart.yaml
sed -r -i "s/ghcr.io\/topolvm\/pie:[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+/ghcr.io\/topolvm\/pie:${{ inputs.app-version }}/g" charts/pie/Chart.yaml
- name: Issue an access token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.PROJECT_APP_ID }}
private-key: ${{ secrets.PROJECT_APP_PEM }}
- name: "Create pull request"
run: |
git commit -a -s -m "Bump chart version to ${{ inputs.chart-version }}"
git push --set-upstream origin bump-chart-${{ inputs.chart-version }}
gh pr create --draft --fill
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}