Pull Request Description | Jira Ticket |
---|---|
- Create a file
jira-pr-action.yml
in the.github/workflows
directory in your repository with the following content:
name: Update PR Description from Jira
on:
pull_request:
types:
- opened
- synchronize
- reopened
- edited
jobs:
update_pr_description:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Update PR description
id: update_description
uses: sylwek845/Jira-PR-Info@1.0.4
with:
token: ${{secrets.GITHUB_TOKEN}} # required
orgUrl: https://testcompany.atlassian.net # required
jiraToken: ${{secrets.JIRA_TOKEN}} # required
jiraUsername: ${{secrets.JIRA_USERNAME}} # required
addIdToTitle: true
skipLabel: no-id-pr
failWhenNoId: true
Name | Description | Example | Required |
---|---|---|---|
token |
Automatically generated repo scoped token, provided by Github by default. configure read and write permissions for the workflow. | ${{ secrets.GITHUB_TOKEN }} | Yes |
orgUrl |
Organisation's sub-domain for Jira . | https://sub-domain.atlassian.net | Yes |
jiraToken |
Project scoped Jira API token for Authorization. check here for configuring the Jira API token into your Repo | ${{secrets.JIRA_API_TOKEN}} | Yes |
jiraUsername |
Email address or username of the user account in Jira from which the jiraToken was obtained refer . |
${{secrets.JIRA_USERNAME}} | Yes |
addIdToTitle |
If set to true and ID is missing from title, the action will add it. | true/false | No |
skipLabel |
You can opt in to skip failing if the PR is label exist in the title, for example if PR title is SKIP - Update DB and value is set to SKIP it will not fail the PR. |
Any | No |
failWhenNoId |
Set if Action should fail if Jira Id does not exist in the PR | true/false | No |
The output will be places between <!--jira-body-here-start-->
and <!--jira-body-here-end-->
in the body of the PR.
in your body (ideally template)
This will be replaced by the output of the action.
Warning
Action result - the action will fail the workflow in case required input fields provided are incorrect or invalid .
- Jira API token can be obtained from the account settings in Jira , reference .
- Jira API token should be added to repository secrets with the desired name for the token value .
- The Jira username must correspond to the email address of the user account used to generate the Jira API token. This username should be set as a secret key in the repository's secrets under the chosen name for the username value.
Note
This build makes use of Jira REST API V2, which means that the Markdown formatting in Jira and GitHub pull requests may not perfectly align. While certain advanced formatting features may not translate precisely, basic elements like plain text, bullet points, and paragraphs remain consistent between the two platforms.
[!Contribution] Please raise a Pull Request to contribute. Remember to run
ncc build src/index.js
-> More info https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action
[!TODO]
- Try to fetch attachments and link them to github using urls
This action is based on https://github.com/ks-keshava-rao/Jira-description