Jira action triggers a Github action

Victoria Lee April 7, 2021

I'm wondering if there is a way for a change in status on jira issue to trigger a github action, like merging a pull request. 

I know you can use webhooks to send PR information to linked jira issues and change the issue status, I'm wondering if the reverse can be done. Can jira send information back to github?

1 answer

1 accepted

0 votes
Answer accepted
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 9, 2021

Hello @Victoria Lee ,

Welcome to the Atlassian Community!

If I understand correctly you would like to trigger a github action automatically, when an issue in Jira changes status.

Now, if my understanding is correct, you should be able to achieve this by creating an Automation Rule (either global or specific to a project) that on the desired status change will send a REST API request to, for example, the GitHub Pull Request API (allows you to list, view, edit, create, and even merge pull requests. Comments on pull requests can be managed via the Issue Comments API).

 

For further details and examples please see:

 

I hope this helps.

 

Cheers,
Dario

Hemant Goel June 22, 2022

Hi Dario

have a question, do i need to setup a webhook to send payload to GitHub Repo from JIRA?

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 22, 2022

Hi @Hemant Goel ,

 

As I have written in my comment before you need to use an Automation Rule:

[...] you should be able to achieve this by creating an Automation Rule (either global or specific to a project) that on the desired status change will send a REST API request to, for example, the GitHub Pull Request API [...]

 

This is because, as you can read in below feature request, Jira Webhooks do not support authentication:

Like Hemant Goel likes this
Hemant Goel June 22, 2022

thanks @Dario B 

appreciate your quick response. I got your point but when i set up an action, i do get only option as Submit Web Request and that only asks for WebHooks. I tried to provide RestAPI URL which works locally with me, but in Jira i always get 404 response. Is there any other action i should try for RestAPI.jira_automation.PNG

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 22, 2022

@Hemant Goel , 

 

Please notice that 404 means page not found and therefore there are chances you are calling the wrong URL. Also, I don't see any authorization header configured.

Can you confirm that you are trying to call the below endpoint?

 

If that's correct, can you run the same REST API call using Curl as per the example in above page and paste the result in here (making sure to remove all the sensitive data like username, auth token, auth header, etc).

curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ https://api.github.com/repos/OWNER/REPO/actions/runs
Like Hemant Goel likes this
Hemant Goel June 23, 2022

Thanks @Dario B 

As i need to fetch data from a organization repo, so had to use this URL:

https://api.github.com/repos/tr/DellBoomi_Test/actions/workflows

and getting response (not adding full response here)

{
"total_count": 10,
"workflows": [
{
"id": 24466375,
"node_id": "W_kwDOEt2HOs4BdVPH",
"name": "API test",
"path": ".github/workflows/API.yml",
"state": "active",
"created_at": "2022-04-19T16:56:49.000+01:00",
"updated_at": "2022-05-17T11:43:10.000+01:00",
"url": "https://api.github.com/repos/tr/DellBoomi_Test/actions/workflows/24466375",
"html_url": "https://github.com/tr/DellBoomi_Test/blob/master/.github/workflows/API.yml",
"badge_url": "https://github.com/tr/DellBoomi_Test/workflows/API%20test/badge.svg"
},

 

Curl command I used:

curl -i -H "Accept: application/vnd.github.v3+json" -H "Authorization: token [token]" https://api.github.com/repos/tr/DellBoomi_Test/actions/workflows

Hemant Goel June 23, 2022

And with runs option also getting good response

curl -i -H "Accept: application/vnd.github.v3+json" -H "Authorization: token [token]" https://api.github.com/repos/tr/DellBoomi_Test/actions/runs

{
"total_count": 389,
"workflow_runs": [
{
"id": 2516519596,
"name": "Get_Extension",
"node_id": "WFR_kwLOEt2HOs6V_wqs",
"head_branch": "testbranch",
"head_sha": "a994b74d3a5dbd7665004c96dc9532190f5b55b0",
"path": ".github/workflows/getAPI.yml",
"run_number": 15,
"event": "push",
"status": "completed",
"conclusion": "failure",
"workflow_id": 28156276,
"check_suite_id": 6981026234,
"check_suite_node_id": "CS_kwDOEt2HOs8AAAABoBoBug",
"url": "https://api.github.com/repos/tr/DellBoomi_Test/actions/runs/2516519596",
"html_url": "https://github.com/tr/DellBoomi_Test/actions/runs/2516519596",
"pull_requests": [
{
"url": "https://api.github.com/repos/tr/DellBoomi_Test/pulls/10",

Hemant Goel June 23, 2022

I can get the response using this as well:

https://api.github.com/repos/tr/DellBoomi_Test/actions/workflows

{
"total_count": 10,
"workflows": [
{
"id": 24466375,
"node_id": "W_kwDOEt2HOs4BdVPH",
"name": "API test",
"path": ".github/workflows/API.yml",
"state": "active",
"created_at": "2022-04-19T16:56:49.000+01:00",
"updated_at": "2022-05-17T11:43:10.000+01:00",
"url": "https://api.github.com/repos/tr/DellBoomi_Test/actions/workflows/24466375",
"html_url": "https://github.com/tr/DellBoomi_Test/blob/master/.github/workflows/API.yml",
"badge_url": "https://github.com/tr/DellBoomi_Test/workflows/API%20test/badge.svg"
},
{
"id": 26215799,
"node_id": "W_kwDOEt2HOs4BkAV3",
"name": "Main_pipeline",
"path": ".github/workflows/Main_Pipeline.yml",

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 23, 2022

@Hemant Goel 

Try if adding the authorization header to the automation rule makes any difference. 

If it doesn't, expand the error message and check the automation rule logs for more details on what's failing.

Finally, if nothing helps, it could be a good idea to create a support request using below link in order to have your issue investigated: 

Hemant Goel June 23, 2022

Hi @Dario B first of all many thanks for your support and a big apology from my end, i found the mistake was making during this run, forgot to pick right HTTP method according to different API, now its all sorted and working fine. Thanks a lot.jira_automation01.PNG

Like Dario B likes this
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 23, 2022

Nice one @Hemant Goel ! Mistakes happens, the important thing is that this is now working :) 

 

Have a nice day!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events