feat: Add change-description field to upgrade-one-dep workflow (#32214)
This will allow people to optionally describe the dependency upgrade without having to rewrite the auto-generated commit or edit the PR body. (The PR body isn't even guaranteed to make it into the eventual merged commit.)
This commit is contained in:
@@ -12,6 +12,11 @@ on:
|
||||
description: 'Name of package to upgrade'
|
||||
required: true
|
||||
type: string
|
||||
change_desc:
|
||||
description: |
|
||||
Description of change, for commit message and PR. (What does the new version add or fix?)
|
||||
default: ''
|
||||
type: string
|
||||
|
||||
defaults:
|
||||
run:
|
||||
@@ -39,13 +44,29 @@ jobs:
|
||||
make upgrade-package package="$PACKAGE"
|
||||
|
||||
- name: PR preflight
|
||||
env:
|
||||
CHANGE_DESC: "${{ inputs.change_desc }}"
|
||||
run: |
|
||||
if git diff --exit-code; then
|
||||
# Fail early (and avoid quiet failure of create-pull-request action)
|
||||
echo "Error: No changes, so not creating PR." | tee -a "$GITHUB_STEP_SUMMARY"
|
||||
exit 1
|
||||
else
|
||||
: # do nothing; exit code 1 means there are changes (good!)
|
||||
# There are changes to commit, so prep some info for the PR.
|
||||
|
||||
# This is honestly a lot to go through just to say "add two newlines
|
||||
# on the end if the variable isn't empty" but I guess this is what we
|
||||
# have to do to get a conditional delimiter.
|
||||
if [[ -z "$CHANGE_DESC" ]]; then
|
||||
echo "body_prefix=" >> "$GITHUB_ENV"
|
||||
else
|
||||
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
|
||||
echo "body_prefix<<$EOF" >> "$GITHUB_ENV"
|
||||
echo "$CHANGE_DESC" >> "$GITHUB_ENV"
|
||||
echo "" >> "$GITHUB_ENV"
|
||||
echo "" >> "$GITHUB_ENV"
|
||||
echo "$EOF" >> "$GITHUB_ENV"
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Make a PR
|
||||
@@ -58,9 +79,10 @@ jobs:
|
||||
commit-message: |
|
||||
feat: Upgrade Python dependency ${{ inputs.package }}
|
||||
|
||||
Commit generated by workflow `${{ github.workflow_ref }}`
|
||||
${{ env.body_prefix }}Commit generated by workflow `${{ github.workflow_ref }}`
|
||||
title: "feat: Upgrade Python dependency ${{ inputs.package }}"
|
||||
body: "PR generated by workflow `${{ github.workflow_ref }}` on behalf of @${{ github.triggering_actor }}."
|
||||
body: |
|
||||
${{ env.body_prefix }}PR generated by workflow `${{ github.workflow_ref }}` on behalf of @${{ github.triggering_actor }}.
|
||||
assignees: "${{ github.triggering_actor }}"
|
||||
|
||||
- name: Job summary
|
||||
|
||||
Reference in New Issue
Block a user