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 05e0ff0 commit 0a544e6
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/repair-pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,20 @@ jobs:

steps:

- name: Fetch PR and extract title
id: pr_title
- name: Repair PR title
run: |
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 }}")
TITLE="$(jq '.title' <<< "$PR")"
echo "title=$TITLE" >> $GITHUB_OUTPUT
shell: bash

- name: Update PR title
run: |
ORIGINAL_TITLE=$(jq -r <<< ${{ steps.pr_title.outputs.title }})
UPDATED_TITLE=$(echo "$ORIGINAL_TITLE" | sed -E 's/vacms ([0-9]+) /VACMS-\1: /I')
ORIGINAL_TITLE="$(jq '.title' <<< "$PR")"
UPDATED_TITLE="$(echo "$ORIGINAL_TITLE" | sed -E 's/vacms ([0-9]+) /VACMS-\1: /I')"
if [ "$ORIGINAL_TITLE" != "$UPDATED_TITLE" ]; then
ESCAPED_UPDATED_TITLE=$(jq -R -s -j <<< "$UPDATED_TITLE")
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 }}" \
-d "{\"title\":$ESCAPED_UPDATED_TITLE}"
-d "{\"title\":$UPDATED_TITLE}"
fi
shell: bash

0 comments on commit 0a544e6

Please sign in to comment.