630-fix: Hydration error on prod (DO NOT MERGE) #99
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto PR Title | |
on: | |
pull_request: | |
types: [opened] | |
jobs: | |
update-pr-title: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the code | |
uses: actions/checkout@v4 | |
- name: Extract branch number and update PR title | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
PR_NUMBER="${{ github.event.number }}" | |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}" | |
PR_TITLE="${{ github.event.pull_request.title }}" | |
if [[ "$BRANCH_NAME" =~ ^(feat|fix|refactor|docs|chore|test)\/([0-9]{1,5})-([a-zA-Z0-9-]{2,})$ ]]; | |
then | |
TYPE="${BASH_REMATCH[1]}" | |
NUMBER="${BASH_REMATCH[2]}" | |
DESCRIPTION="${BASH_REMATCH[3]}" | |
else | |
echo "Branch name does not match the required pattern. Exiting." | |
exit 0 | |
fi | |
FORMATTED_DESCRIPTION=$(echo "$DESCRIPTION" | sed -E 's/-/ /g' | awk '{print toupper(substr($1,1,1)) tolower(substr($1,2)) substr($0,length($1)+1)}') | |
NEW_TITLE="$NUMBER-$TYPE: $FORMATTED_DESCRIPTION" | |
echo "Updating PR title to: $NEW_TITLE" | |
curl -X PATCH \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER \ | |
-d "{\"title\":\"$NEW_TITLE\"}" |