Skip to content

Commit

Permalink
Update repair-pr-title.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ndouglas authored May 30, 2023
1 parent 0a544e6 commit bb09b18
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/repair-pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,34 @@ jobs:

- name: Repair PR title
run: |
PR=$(curl \
PR_API_URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}"
# Retrieve the PR object.
PR="$(curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}")
"${PR_API_URL}")
echo "PR: $PR"
# This will be a JSON-quoted string. We do _not_ strip the quotes.
# For instance (pathological example):
# "Bump drupal/coder from 8.3.17 to 8.3.18\" ' } \\\" ' 4"
ORIGINAL_TITLE="$(jq '.title' <<< "$PR")"
echo "ORIGINAL_TITLE: $ORIGINAL_TITLE"
# Fix the prefix. This should preserve everything else.
UPDATED_TITLE="$(echo "$ORIGINAL_TITLE" | sed -E 's/vacms ([0-9]+) /VACMS-\1: /I')"
echo "UPDATED_TITLE: $UPDATED_TITLE"
if [ "$ORIGINAL_TITLE" != "$UPDATED_TITLE" ]; then
echo "Updating PR title from $ORIGINAL_TITLE to $UPDATED_TITLE"
# $UPDATED_TITLE is already quoted, so we must not quote it again.
curl \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" \
"${PR_API_URL}" \
-d "{\"title\":$UPDATED_TITLE}"
fi
shell: bash

0 comments on commit bb09b18

Please sign in to comment.