Skip to content

Commit

Permalink
PORT-8075 | Update GitHub actions for SonarQube, Jira and Datadog (#1220
Browse files Browse the repository at this point in the history
)

* PORT-8075 | Control the payload for Jira, SonarQube, Datadog

* PORT-8075 | Update input variables for actions with port context

---------

Co-authored-by: lord-sarcastic <>
  • Loading branch information
lordsarcastic committed May 26, 2024
1 parent d734a6e commit fd787ab
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 246 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,32 +119,21 @@ name: Trigger Datadog Incident
on:
workflow_dispatch:
inputs:
customerImpactScope:
title:
type: string
customerImpacted:
type: boolean
title:
required: true
customerImpactScope:
type: string
description: Required if customer_impacted:"true". A summary of the impact customers experienced during the incident.
notificationHandleName:
type: string
notificationHandleEmail:
type: string
port_payload:
port_context:
required: true
description: Port's payload, including details for who triggered the action and
general context (blueprint, run id, etc...)
type: string
secrets:
DD_API_KEY:
required: true
DD_APPLICATION_KEY:
required: true
DD_API_URL:
required: true
PORT_CLIENT_ID:
required: true
PORT_CLIENT_SECRET:
required: true
jobs:
create-entity-in-port-and-update-run:

Expand All @@ -157,7 +146,7 @@ jobs:
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: PATCH_RUN
runId: ${{fromJson(inputs.port_payload).context.runId}}
runId: ${{ fromJson(inputs.port_context).run_id }}
logMessage: Starting request to create Datadog incident

- name: Create a Datadog incident
Expand All @@ -176,7 +165,7 @@ jobs:
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: PATCH_RUN
runId: ${{fromJson(inputs.port_payload).context.runId}}
runId: ${{ fromJson(inputs.port_context).run_id }}
logMessage: Finished request to create Datadog incident

- name: Inform ingestion of Datadog incident into Port
Expand All @@ -186,7 +175,7 @@ jobs:
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: PATCH_RUN
runId: ${{fromJson(inputs.port_payload).context.runId}}
runId: ${{ fromJson(inputs.port_context).run_id }}
logMessage: Ingesting Datadog incident into Port

- name: Convert dates to desired format
Expand All @@ -206,7 +195,7 @@ jobs:
with:
identifier: ${{ fromJson(steps.datadog_incident.outputs.response).data.id }}
title: ${{ fromJson(steps.datadog_incident.outputs.response).data.attributes.title }}
blueprint: datadogIncident
blueprint: ${{ fromJson(inputs.port_context).blueprint }}
properties: |-
{
"customerImpactScope": "${{ fromJson(steps.datadog_incident.outputs.response).data.attributes.customer_impact_scope }}",
Expand All @@ -227,7 +216,7 @@ jobs:
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: UPSERT
runId: ${{fromJson(inputs.port_payload).context.runId}}
runId: ${{ fromJson(inputs.port_context).run_id }}

- name: Inform completion of Datadog incident ingestion into Port
uses: port-labs/port-github-action@v1
Expand All @@ -236,7 +225,7 @@ jobs:
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: PATCH_RUN
runId: ${{fromJson(inputs.port_payload).context.runId}}
runId: ${{ fromJson(inputs.port_context).run_id }}
link: ${{ secrets.DD_API_URL }}/incidents/${{ fromJson(steps.datadog_incident.outputs.response).data.id }}
logMessage: Finished request to ingest Datadog incident into Port

Expand All @@ -247,7 +236,7 @@ jobs:
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: PATCH_RUN
runId: ${{ fromJson(inputs.port_payload).context.runId }}
runId: ${{ fromJson(inputs.port_context).run_id }}
logMessage: Workflow completed
```

Expand All @@ -274,27 +263,32 @@ Make sure to replace `<GITHUB_ORG>` and `<GITHUB_REPO>` with your GitHub organiz
"operation": "CREATE",
"userInputs": {
"properties": {
"customerImpactScope": {
"title": "Customer Impact Scope",
"description": "A summary of the impact customers experienced during the incident.",
"type": "string"
},
"customerImpacted": {
"icon": "DefaultProperty",
"title": "Customer Impacted",
"description": "A flag indicating whether the incident caused customer impact.",
"type": "boolean"
"type": "boolean",
"default": false
},
"customerImpactScope": {
"icon": "DefaultProperty",
"title": "Customer Impact Scope",
"description": "A summary of the impact customers experienced during the incident. Required if \"Customer Impacted\" is true.",
"type": "string"
},
"title": {
"title": "Title",
"description": "The title of the incident, which summarizes what happened.",
"type": "string"
},
"notificationHandleName": {
"icon": "DefaultProperty",
"title": "Notification Handle Name",
"type": "string",
"description": "The name of the notified handle."
},
"notificationHandleEmail": {
"icon": "DefaultProperty",
"title": "Notification Handle Email",
"description": "The email address used for the notification.",
"type": "string",
Expand All @@ -303,7 +297,10 @@ Make sure to replace `<GITHUB_ORG>` and `<GITHUB_REPO>` with your GitHub organiz
},
"required": [
"customerImpacted",
"title"
"title",
"customerImpactScope",
"notificationHandleName",
"notificationHandleEmail"
],
"order": [
"title",
Expand All @@ -317,49 +314,18 @@ Make sure to replace `<GITHUB_ORG>` and `<GITHUB_REPO>` with your GitHub organiz
},
"invocationMethod": {
"type": "GITHUB",
"org": "<Enter GitHub organization>",
"repo": "<Enter GitHub repository>",
"org": "<Enter GitHub organization>",
"workflow": "trigger-datadog-incident.yml",
"workflowInputs": {
"{{if (.inputs | has(\"ref\")) then \"ref\" else null end}}": "{{.inputs.\"ref\"}}",
"{{if (.inputs | has(\"customerImpactScope\")) then \"customerImpactScope\" else null end}}": "{{.inputs.\"customerImpactScope\"}}",
"{{if (.inputs | has(\"customerImpacted\")) then \"customerImpacted\" else null end}}": "{{.inputs.\"customerImpacted\"}}",
"{{if (.inputs | has(\"title\")) then \"title\" else null end}}": "{{.inputs.\"title\"}}",
"{{if (.inputs | has(\"notificationHandleName\")) then \"notificationHandleName\" else null end}}": "{{.inputs.\"notificationHandleName\"}}",
"{{if (.inputs | has(\"notificationHandleEmail\")) then \"notificationHandleEmail\" else null end}}": "{{.inputs.\"notificationHandleEmail\"}}",
"port_payload": {
"action": "{{ .action.identifier[(\"datadogIncident_\" | length):] }}",
"resourceType": "run",
"status": "TRIGGERED",
"trigger": "{{ .trigger | {by, origin, at} }}",
"context": {
"entity": "{{.entity.identifier}}",
"blueprint": "{{.action.blueprint}}",
"runId": "{{.run.id}}"
},
"payload": {
"entity": "{{ (if .entity == {} then null else .entity end) }}",
"action": {
"invocationMethod": {
"type": "GITHUB",
"repo": "<Enter GitHub repository>",
"org": "<Enter GitHub organization>",
"workflow": "trigger-datadog-incident.yml",
"omitUserInputs": false,
"omitPayload": false,
"reportWorkflowStatus": true
},
"trigger": "{{.trigger.operation}}"
},
"properties": {
"{{if (.inputs | has(\"customerImpactScope\")) then \"customerImpactScope\" else null end}}": "{{.inputs.\"customerImpactScope\"}}",
"{{if (.inputs | has(\"customerImpacted\")) then \"customerImpacted\" else null end}}": "{{.inputs.\"customerImpacted\"}}",
"{{if (.inputs | has(\"title\")) then \"title\" else null end}}": "{{.inputs.\"title\"}}",
"{{if (.inputs | has(\"notificationHandleName\")) then \"notificationHandleName\" else null end}}": "{{.inputs.\"notificationHandleName\"}}",
"{{if (.inputs | has(\"notificationHandleEmail\")) then \"notificationHandleEmail\" else null end}}": "{{.inputs.\"notificationHandleEmail\"}}"
},
"censoredProperties": "{{.action.encryptedProperties}}"
}
"customerImpactScope": "{{.inputs.\"customerImpactScope\"}}",
"customerImpacted": "{{.inputs.\"customerImpacted\"}}",
"title": "{{.inputs.\"title\"}}",
"notificationHandleName": "{{.inputs.\"notificationHandleName\"}}",
"notificationHandleEmail": "{{.inputs.\"notificationHandleEmail\"}}",
"port_context": {
"blueprint": "{{.action.blueprint}}",
"run_id": "{{.run.id}}"
}
},
"reportWorkflowStatus": true
Expand Down
Loading

0 comments on commit fd787ab

Please sign in to comment.