This guide explains how to ingest the status of a specific job inside a GitHub workflow run to Port.
Note: this guide assumes you are already using Port's GitHub app and you are ingesting into Port you GitHub workflow runs
To implement this functionality, you will use Port’s webhook feature.
Here are the steps you need to follow:
- Add a
job_status
string property to the Workflow Run blueprint- This step is optional, if you just want to override the general status of the workflow run entity with the status of the desired step, you can skip this and update the JQ provided below accordingly
- Create a webhook in Port, to do that follow these steps:
- Go to the app.getport.io
- Open the builder page
- Click on the
data sources
button on the left side of the page - Click on the
+ Data source
button at the top right corner of the page - Select the Webhook tab
- Click on the custom integration box
- In the new window, enter the title and select an icon for the webhook, then click on next
- In the integration configuration step, take a look at the numbered boxes
- The first box includes the URL for the webhook, save it as we will provide it to GitHub when configuring the webhook on their side
- You can ignore the second box
- For the third box, use the config provided below
- Click on next and then on create at the next page
- Create a webhook in GitHub, to do that follow these steps:
- Go to the github repository with the desired workflow
- Click on Settings
- Click on webhooks
- Click on add webhook
- For the payload URL, use the URL Port provided when you created the webhook on Port’s side (it starts with https://ingest.getport.io…)
- For the content type, select
application/json
- You can leave secret empty
- For “which events…“, select - Let me select individual events, and then select Workflow jobs and also deselect pushes
- Click on Add webhook
Now let’s take a look at the webhook configuration on Port’s side, you will notice this snippet includes some placeholders for YOUR_WORKFLOW_NAME
and YOUR_WORKFLOW_JOB_NAME
, These correspond to the workflow name itself, and then to the specific job you want to take the status from.
As mentioned above, it is possible to override the existing status of the workflow run entity, with the status of the specific job in the workflow, to do that, simply replace the job_status
key in the configuration below, with status
[
{
"blueprint": "workflowRun",
"filter": ".body.workflow_job.workflow_name == \"YOUR_WORKFLOW_NAME\" and .body.workflow_job.name == \"YOUR_WORKFLOW_JOB_NAME\" and .body.workflow_job.status == \"completed\"",
"entity": {
"identifier": ".body.repository.name + (.body.workflow_job.run_id | tostring)",
"properties": {
"job_status": ".body.workflow_job.conclusion"
}
}
}
]