Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/pr-branch-info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Add branch info to PR description

on:
pull_request:
types: [opened, reopened]

permissions:
pull-requests: write

jobs:
add-branch-info:
runs-on: ubuntu-latest
steps:
- name: Append branch info to PR description
env:
GH_TOKEN: ${{ github.token }}
PR_SOURCE_USER: ${{ github.event.pull_request.head.user.login }}
PR_TARGET_USER: ${{ github.event.pull_request.base.user.login }}
PR_HEAD_REF: ${{ github.head_ref }}
PR_BASE_REF: ${{ github.base_ref }}
run: |
PR_NUMBER="${{ github.event.pull_request.number }}"
CURRENT_BODY="$(gh pr view "$PR_NUMBER" --repo "${{ github.repository }}" --json body --jq '.body // ""')"

if printf '%s' "$CURRENT_BODY" | grep -q '<!-- branch-info -->'; then
echo "Branch info already present, skipping."
exit 0
fi

{
printf '%s\n' "$CURRENT_BODY"
printf '\n'
printf '%s\n' '<!-- branch-info (auto-generated by workflow, do not edit) -->'
printf '%s\n' '## Branch info'
printf '\n'
printf '%s\n' "- Source user: \`$PR_SOURCE_USER\`"
printf '%s\n' "- Source branch: \`$PR_HEAD_REF\`"
printf '%s\n' "- Target user: \`$PR_TARGET_USER\`"
printf '%s\n' "- Target branch: \`$PR_BASE_REF\`"
} > "$RUNNER_TEMP/body.md"

gh pr edit "$PR_NUMBER" --repo "${{ github.repository }}" --body-file "$RUNNER_TEMP/body.md"
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Please mark all change in change log and use the issue from GitHub
- [#56](https://github.com/BossZou/jaclks/pull/56) cancel windows platform support
- [#58](https://github.com/BossZou/jaclks/pull/58) Remove windows support badge and update Supported Platforms
- [#61](https://github.com/BossZou/jaclks/pull/61) Set BossZou as project code onwer
- [#65](https://github.com/BossZou/jaclks/pull/65) Annotate PR descriptions with source/target branch and user info

## Document
- [#22](https://github.com/BossZou/jaclks/pull/22) Add license Apache 2.0 and code quality badge
Expand Down
Loading