-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify PR template body and create github action to add Jira issue
- Loading branch information
1 parent
18ccb29
commit aa37d8c
Showing
2 changed files
with
42 additions
and
19 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,5 @@ | ||
Fixes #issuenumber ; refs #issuenumber | ||
### Link to Jira Issue | ||
[Link will be automatically added here. Do not remove.] | ||
|
||
Present short summary (50 characters or less) | ||
|
||
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. | ||
|
||
Description can have multiple paragraphs and you can use code examples inside: | ||
|
||
``` ruby | ||
class PostsController | ||
def index | ||
respond_with Post.limit(10) | ||
end | ||
end | ||
``` | ||
|
||
Changes proposed in this pull request: | ||
* | ||
* | ||
* | ||
### Description | ||
<!-- Provide a description of what was changed and why --> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Update Pull Request with Jira Issue Link | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited] | ||
|
||
jobs: | ||
update-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Extract Jira Issue from branch name | ||
run: | | ||
branch_name=$(echo "${{ github.event.pull_request.head.ref }}" | grep -oE 'LIBAAEC-[0-9]+') | ||
if [ -z "$branch_name" ]; then | ||
echo "No Jira issue found in branch name." | ||
exit 0 | ||
fi | ||
jira_link="https://ucdts.atlassian.net/browse/$branch_name" | ||
placeholder_exists=$(echo "${{ github.event.pull_request.body }}" | grep -c '\[Link will be automatically added here. Do not remove.\]') | ||
if [ "$placeholder_exists" -eq 1 ]; then | ||
# If the placeholder exists, replace it with the Jira link | ||
pr_body=$(echo "${{ github.event.pull_request.body }}" | sed "s|\[Link will be automatically added here. Do not remove.\]|[$branch_name]($jira_link)|") | ||
else | ||
# If the placeholder is missing, append the Jira link to the top of the PR description | ||
pr_body="### Link to Jira Issue\n[$branch_name]($jira_link)\n\n${{ github.event.pull_request.body }}" | ||
fi | ||
echo "$pr_body" > pr_body.txt | ||
- name: Update Pull Request Description | ||
uses: peter-evans/repository-dispatch@v2 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
event-type: pull-request-edited | ||
client-payload: '{"pull_request_number": ${{ github.event.pull_request.number }}, "pr_body": "$(cat pr_body.txt)"}' |