-
Notifications
You must be signed in to change notification settings - Fork 800
155 lines (144 loc) · 5.01 KB
/
Copy pathupdate-chart-app-version.yaml
File metadata and controls
155 lines (144 loc) · 5.01 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Update Chart App Version
on:
workflow_call:
secrets:
OTELBOT_PRIVATE_KEY:
required: true
inputs:
chart_name:
required: true
type: string
chart_root:
required: true
type: string
chart_yaml:
required: true
type: string
stage_path:
required: true
type: string
upstream_repository:
required: true
type: string
release_tag_prefix:
required: true
type: string
app_version_prefix:
required: true
type: string
branch_prefix:
required: true
type: string
version_policy:
required: true
type: string
approvers:
required: true
type: string
pr_title_template:
required: true
type: string
pr_body_template:
required: true
type: string
post_update_action:
# `workflow_call` inputs do not support `choice`, so this remains a string
# and is validated against an allowlist in the updater script.
required: false
type: string
default: "none"
release_tag:
required: false
type: string
default: ""
permissions:
contents: read
concurrency:
group: update-chart-app-version-${{ inputs.chart_name }}
cancel-in-progress: false
jobs:
update:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup
with:
create-kind-cluster: "false"
helm-version: "v4.0.5"
- name: Update chart
id: update
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ inputs.release_tag }}
CHART_NAME: ${{ inputs.chart_name }}
CHART_ROOT: ${{ inputs.chart_root }}
CHART_YAML: ${{ inputs.chart_yaml }}
STAGE_PATH: ${{ inputs.stage_path }}
UPSTREAM_REPOSITORY: ${{ inputs.upstream_repository }}
RELEASE_TAG_PREFIX: ${{ inputs.release_tag_prefix }}
APP_VERSION_PREFIX: ${{ inputs.app_version_prefix }}
BRANCH_PREFIX: ${{ inputs.branch_prefix }}
VERSION_POLICY: ${{ inputs.version_policy }}
APPROVERS: ${{ inputs.approvers }}
PR_TITLE_TEMPLATE: ${{ inputs.pr_title_template }}
PR_BODY_TEMPLATE: ${{ inputs.pr_body_template }}
POST_UPDATE_ACTION: ${{ inputs.post_update_action }}
run: .github/scripts/update-chart-app-version.sh
- name: Use CLA approved GitHub bot
if: steps.update.outputs.changed == 'true'
run: |
git config user.name otelbot
git config user.email 197425009+otelbot@users.noreply.github.com
- name: Push update branch if needed
if: steps.update.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: ${{ steps.update.outputs.branch_name }}
COMMIT_MESSAGE: ${{ steps.update.outputs.commit_message }}
STAGE_PATH: ${{ steps.update.outputs.stage_path }}
run: |
auth_header="$(printf 'x-access-token:%s' "${GH_TOKEN}" | base64 | tr -d '\n')"
git checkout -B "${BRANCH_NAME}"
git add "${STAGE_PATH}"
git commit -m "${COMMIT_MESSAGE}"
git -c http.https://github.com/.extraheader="AUTHORIZATION: basic ${auth_header}" \
push --force-with-lease --set-upstream origin "${BRANCH_NAME}"
- name: Create OTelBot token
if: steps.update.outputs.changed == 'true'
id: otelbot-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ vars.OTELBOT_CLIENT_ID }}
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: ${{ github.event.repository.name }}
permission-pull-requests: write
- name: Create pull request if needed
if: steps.update.outputs.changed == 'true'
env:
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
BRANCH_NAME: ${{ steps.update.outputs.branch_name }}
PR_TITLE: ${{ steps.update.outputs.pr_title }}
PR_BODY: ${{ steps.update.outputs.pr_body }}
run: |
pr_number="$(gh pr list --head "${BRANCH_NAME}" --base main --json number --jq '.[0].number // empty')"
if [[ -n "${pr_number}" ]]; then
gh pr edit "${pr_number}" \
--title "${PR_TITLE}" \
--body "${PR_BODY}"
else
gh pr create \
--head "${BRANCH_NAME}" \
--base main \
--title "${PR_TITLE}" \
--body "${PR_BODY}"
fi