Skip to content

Commit 167f32a

Browse files
authored
ci(generate_prs): Add custom PR title support (#504)
1 parent 1ba8fc4 commit 167f32a

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.github/workflows/generate_prs.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
message:
1010
description: "Message to include in the generated commits:"
1111
required: true
12+
custom-pr-title:
13+
description: "Optionally a custom PR title. If unset, default will be used"
1214
dry-run:
1315
description: "Dry Run (PRs are not generated)"
1416
type: boolean
@@ -155,12 +157,18 @@ jobs:
155157
# Generate PRs
156158
- name: Run playbook
157159
if: ${{ !inputs.dry-run }}
160+
env:
161+
CUSTOM_PR_TITLE: ${{ inputs.custom-pr-title }}
162+
GH_ACCESS_TOKEN: ${{ secrets.gh_access_token }}
158163
run: |
159164
# Funnel via JSON to ensure that values are escaped properly
160-
echo '{}' | jq '{commit_hash: $ENV.GITHUB_SHA, author: $ENV.AUTHOR, reason: $ENV.REASON, base_dir: $pwd, gh_access_token: $ENV.GH_ACCESS_TOKEN}' --arg pwd "$(pwd)" > vars.json
165+
# Check if custom PR title is set. If so, insert it into the extra vars
166+
if [ -n "$CUSTOM_PR_TITLE" ]; then
167+
echo '{}' | jq '{commit_hash: $ENV.GITHUB_SHA, author: $ENV.AUTHOR, reason: $ENV.REASON, custom_pr_title: $ENV.CUSTOM_PR_TITLE, base_dir: $pwd, gh_access_token: $ENV.GH_ACCESS_TOKEN}' --arg pwd "$(pwd)" > vars.json
168+
else
169+
echo '{}' | jq '{commit_hash: $ENV.GITHUB_SHA, author: $ENV.AUTHOR, reason: $ENV.REASON, base_dir: $pwd, gh_access_token: $ENV.GH_ACCESS_TOKEN}' --arg pwd "$(pwd)" > vars.json
170+
fi
161171
ansible-playbook playbook/playbook.yaml --extra-vars "@vars.json"
162-
env:
163-
GH_ACCESS_TOKEN: ${{ secrets.gh_access_token }}
164172
165173
# Do Not Generate PRs
166174
- name: Run playbook (dry-run)

playbook/group_vars/all/vars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ commit_message: |
1919
Reference-to: stackabletech/operator-templating@{{ commit_short_hash }} ({{ reason }})
2020

2121
# Title and body of created PRs
22-
pr_title: "chore: Update templated files ({{ commit_short_hash }})"
22+
pr_title: "{{ custom_pr_title | default('chore: Update templated files (' + commit_short_hash + ')') }}"
2323
pr_body: |
2424
> [!NOTE]
2525
> _Autogenerated PR to update templated files since the last template run up to stackabletech/operator-templating@{{ commit_hash }}._

0 commit comments

Comments
 (0)