Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PORT-8075 | Update GitHub actions for SonarQube, Jira and Datadog #1220

Merged
merged 3 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,32 +119,38 @@ 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:
run_id:
required: true
type: string
entity:
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
blueprint:
required: true
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 +163,7 @@ jobs:
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: PATCH_RUN
runId: ${{fromJson(inputs.port_payload).context.runId}}
runId: ${{ inputs.run_id }}
logMessage: Starting request to create Datadog incident

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

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

- name: Convert dates to desired format
Expand All @@ -206,7 +212,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: ${{ inputs.blueprint }}
properties: |-
{
"customerImpactScope": "${{ fromJson(steps.datadog_incident.outputs.response).data.attributes.customer_impact_scope }}",
Expand All @@ -227,7 +233,7 @@ jobs:
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: UPSERT
runId: ${{fromJson(inputs.port_payload).context.runId}}
runId: ${{ inputs.run_id }}

- name: Inform completion of Datadog incident ingestion into Port
uses: port-labs/port-github-action@v1
Expand All @@ -236,7 +242,7 @@ jobs:
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: PATCH_RUN
runId: ${{fromJson(inputs.port_payload).context.runId}}
runId: ${{ inputs.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,8 +253,9 @@ jobs:
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
baseUrl: https://api.getport.io
operation: PATCH_RUN
runId: ${{ fromJson(inputs.port_payload).context.runId }}
runId: ${{ inputs.run_id }}
logMessage: Workflow completed

```

</details>
Expand All @@ -274,15 +281,18 @@ 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",
Expand Down Expand Up @@ -321,46 +331,14 @@ Make sure to replace `<GITHUB_ORG>` and `<GITHUB_REPO>` with your GitHub organiz
"repo": "<Enter GitHub repository>",
"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\"}}",
"entity": "{{.entity.identifier}}",
"blueprint": "{{.action.blueprint}}",
"run_id": "{{.run.id}}"
},
"reportWorkflowStatus": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ on:
assignee:
type: string
required: false
port_payload:
run_id:
required: true
type: string
entity:
required: true
description:
Port's payload, including details for who triggered the action and
general context (blueprint, run id, etc...)
type: string
secrets:
JIRA_BASE_URL:
Expand Down Expand Up @@ -156,13 +156,13 @@ jobs:

- name: Inform starting of changing Jira ticket status
id: inform_ticket_start
if: ${{ github.event.inputs.status }}
if: ${{ inputs.status }}
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
runId: ${{ fromJson(inputs.port_payload).context.runId }}
runId: ${{ inputs.run_id }}
logMessage: |
Changing status of Jira issue... ⛴️

Expand All @@ -174,7 +174,7 @@ jobs:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
runId: ${{ fromJson(inputs.port_payload).context.runId }}
runId: ${{ inputs.run_id }}
logMessage: |
Status field is blank, skipping status change... ⛴️

Expand All @@ -183,8 +183,8 @@ jobs:
if: steps.inform_ticket_start.outcome == 'success'
uses: atlassian/gajira-transition@v3
with:
issue: ${{ fromJson(inputs.port_payload).context.entity }}
transition: ${{ github.event.inputs.status }}
issue: ${{ inputs.entity }}
transition: ${{ inputs.status }}

- name: Inform that status has been changed
if: steps.transition_issue_status.outcome == 'success'
Expand All @@ -193,20 +193,20 @@ jobs:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
link: ${{ secrets.JIRA_BASE_URL }}/browse/${{ fromJson(inputs.port_payload).context.entity }}
runId: ${{ fromJson(inputs.port_payload).context.runId }}
link: ${{ secrets.JIRA_BASE_URL }}/browse/${{ inputs.entity }}
runId: ${{ inputs.run_id }}
logMessage: |
Jira issue status changed to ${{ github.event.inputs.status }}! ✅
Jira issue status changed to ${{ inputs.status }}! ✅

- name: Inform starting of changing Jira ticket assignee
id: inform_assignee_start
if: ${{ github.event.inputs.assignee }}
if: ${{ inputs.assignee }}
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
runId: ${{ fromJson(inputs.port_payload).context.runId }}
runId: ${{ inputs.run_id }}
logMessage: |
Assigning ticket to user... ⛴️

Expand All @@ -218,7 +218,7 @@ jobs:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
runId: ${{ fromJson(inputs.port_payload).context.runId }}
runId: ${{ inputs.run_id }}
logMessage: |
Assignee field is blank, skipping assigning of ticket... ⛴️

Expand All @@ -229,7 +229,7 @@ jobs:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
runId: ${{ fromJson(inputs.port_payload).context.runId }}
runId: ${{ inputs.run_id }}
logMessage: |
Searching for user in organization user list... ⛴️

Expand All @@ -238,7 +238,7 @@ jobs:
if: steps.inform_skip_assignee.outcome == 'skipped'
uses: fjogeleit/http-request-action@v1
with:
url: "${{ secrets.JIRA_BASE_URL }}/rest/api/3/user/search?query=${{ github.event.inputs.assignee }}"
url: "${{ secrets.JIRA_BASE_URL }}/rest/api/3/user/search?query=${{ inputs.assignee }}"
method: "GET"
username: ${{ secrets.JIRA_USER_EMAIL }}
password: ${{ secrets.JIRA_API_TOKEN }}
Expand All @@ -264,9 +264,9 @@ jobs:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
runId: ${{ fromJson(inputs.port_payload).context.runId }}
runId: ${{ inputs.run_id }}
logMessage: |
User found 🥹 Assigning ticket ${{ fromJson(inputs.port_payload).context.entity }} to ${{ steps.user_list_from_search.outputs.selected_user_name }}... ⛴️
User found 🥹 Assigning ticket ${{ inputs.entity }} to ${{ steps.user_list_from_search.outputs.selected_user_name }}... ⛴️

- name: Inform user inexistence
if: steps.user_list_from_search.outputs.selected_user_id == 'empty'
Expand All @@ -275,7 +275,7 @@ jobs:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
runId: ${{ fromJson(inputs.port_payload).context.runId }}
runId: ${{ inputs.run_id }}
logMessage: |
User not found 😭 Skipping assignment... ⛴️

Expand All @@ -284,7 +284,7 @@ jobs:
if: steps.user_list_from_search.outputs.selected_user_id != 'empty'
uses: fjogeleit/http-request-action@v1
with:
url: "${{ secrets.JIRA_BASE_URL }}/rest/api/3/issue/${{ fromJson(inputs.port_payload).context.entity }}/assignee"
url: "${{ secrets.JIRA_BASE_URL }}/rest/api/3/issue/${{ inputs.entity }}/assignee"
method: "PUT"
username: ${{ secrets.JIRA_USER_EMAIL }}
password: ${{ secrets.JIRA_API_TOKEN }}
Expand All @@ -298,11 +298,12 @@ jobs:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
link: ${{ secrets.JIRA_BASE_URL }}/browse/${{ fromJson(inputs.port_payload).context.entity }}
runId: ${{ fromJson(inputs.port_payload).context.runId }}
link: ${{ secrets.JIRA_BASE_URL }}/browse/${{ inputs.entity }}
runId: ${{ inputs.run_id }}
logMessage: |
Jira issue has been assigned to ${{ steps.user_list_from_search.outputs.selected_user_name }}! ✅


```

</details>
Expand Down Expand Up @@ -375,40 +376,10 @@ jobs:
"repo": "<Enter GitHub repository>",
"workflow": "change_jira_ticket_status_and_assignee.yml",
"workflowInputs": {
"{{if (.inputs | has(\"ref\")) then \"ref\" else null end}}": "{{.inputs.\"ref\"}}",
"{{if (.inputs | has(\"status\")) then \"status\" else null end}}": "{{.inputs.\"status\"}}",
"{{if (.inputs | has(\"assignee\")) then \"assignee\" else null end}}": "{{.inputs.\"assignee\"}}",
"port_payload": {
"action": "{{ .action.identifier[(\"jiraIssue_\" | 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",
"org": "<Enter GitHub organization>",
"repo": "<Enter GitHub repository>",
"workflow": "change_jira_ticket_status_and_assignee.yml",
"omitUserInputs": false,
"omitPayload": false,
"reportWorkflowStatus": true
},
"trigger": "{{.trigger.operation}}"
},
"properties": {
"{{if (.inputs | has(\"status\")) then \"status\" else null end}}": "{{.inputs.\"status\"}}",
"{{if (.inputs | has(\"assignee\")) then \"assignee\" else null end}}": "{{.inputs.\"assignee\"}}"
},
"censoredProperties": "{{.action.encryptedProperties}}"
}
}
"status": "{{.inputs.\"status\"}}",
"assignee": "{{.inputs.\"assignee\"}}",
"entity": "{{.entity.identifier}}",
"run_id": "{{.run.id}}"
},
"reportWorkflowStatus": true
},
Expand Down
Loading