Skip to content

480-refactor: Remove css prefixes #108

480-refactor: Remove css prefixes

480-refactor: Remove css prefixes #108

Workflow file for this run

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\"}"