Skip to content

Commit aa37d8c

Browse files
committed
Modify PR template body and create github action to add Jira issue
1 parent 18ccb29 commit aa37d8c

File tree

2 files changed

+42
-19
lines changed

2 files changed

+42
-19
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
1-
Fixes #issuenumber ; refs #issuenumber
1+
### Link to Jira Issue
2+
[Link will be automatically added here. Do not remove.]
23

3-
Present short summary (50 characters or less)
4-
5-
More detailed description, if necessary. Try to be as descriptive as you can: even if you think that the PR content is obvious, it may not be obvious to others. Include tracebacks if helpful, and be sure to call out any bits of the PR that may be work-in-progress.
6-
7-
Description can have multiple paragraphs and you can use code examples inside:
8-
9-
``` ruby
10-
class PostsController
11-
def index
12-
respond_with Post.limit(10)
13-
end
14-
end
15-
```
16-
17-
Changes proposed in this pull request:
18-
*
19-
*
20-
*
4+
### Description
5+
<!-- Provide a description of what was changed and why -->
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Update Pull Request with Jira Issue Link
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited]
6+
7+
jobs:
8+
update-pr:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out code
12+
uses: actions/checkout@v3
13+
14+
- name: Extract Jira Issue from branch name
15+
run: |
16+
branch_name=$(echo "${{ github.event.pull_request.head.ref }}" | grep -oE 'LIBAAEC-[0-9]+')
17+
if [ -z "$branch_name" ]; then
18+
echo "No Jira issue found in branch name."
19+
exit 0
20+
fi
21+
jira_link="https://ucdts.atlassian.net/browse/$branch_name"
22+
placeholder_exists=$(echo "${{ github.event.pull_request.body }}" | grep -c '\[Link will be automatically added here. Do not remove.\]')
23+
24+
if [ "$placeholder_exists" -eq 1 ]; then
25+
# If the placeholder exists, replace it with the Jira link
26+
pr_body=$(echo "${{ github.event.pull_request.body }}" | sed "s|\[Link will be automatically added here. Do not remove.\]|[$branch_name]($jira_link)|")
27+
else
28+
# If the placeholder is missing, append the Jira link to the top of the PR description
29+
pr_body="### Link to Jira Issue\n[$branch_name]($jira_link)\n\n${{ github.event.pull_request.body }}"
30+
fi
31+
echo "$pr_body" > pr_body.txt
32+
33+
- name: Update Pull Request Description
34+
uses: peter-evans/repository-dispatch@v2
35+
with:
36+
token: ${{ secrets.GITHUB_TOKEN }}
37+
event-type: pull-request-edited
38+
client-payload: '{"pull_request_number": ${{ github.event.pull_request.number }}, "pr_body": "$(cat pr_body.txt)"}'

0 commit comments

Comments
 (0)