Skip to content

[Pull Request] Add PR autorename Action. #1

[Pull Request] Add PR autorename Action.

[Pull Request] Add PR autorename Action. #1

Workflow file for this run

name: Check Pull Request Title
on:
pull_request:
types:
- opened
jobs:
check_title:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Comment on Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pull_request_number=${{ github.event.pull_request.number }}
current_title="${{ github.event.pull_request.title }}"
message_body="The origin title of this PR is: '$current_title'. GitHub Action is checking it..."
curl -H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "Content-Type: application/json" \
-X POST \
-d '{"body":"'"$message_body"'"}' \
"https://api.github.com/repos/${{ github.repository }}/issues/$pull_request_number/comments"
- name: Update Pull Request title
run: |
pull_request_number=${{ github.event.pull_request.number }}
current_title="${{ github.event.pull_request.title }}"
updated_title=$(python3 "./.github/pr_autorename.py" "$current_title")
token=${{ secrets.GITHUB_TOKEN }}
curl -X PATCH \
-H "Authorization: Bearer $token" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$pull_request_number" \
-d '{ "title": "'"$updated_title"'" }'