diff --git a/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/acknowledge-incident.md b/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/acknowledge-incident.md index f371de438..344cb6bc6 100644 --- a/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/acknowledge-incident.md +++ b/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/acknowledge-incident.md @@ -70,7 +70,7 @@ jobs: { "incidents": [ { - "id": "${{ fromJson(inputs.port_payload).port_context.entity }}", + "id": "${{ fromJson(inputs.port_context).entity }}", "type": "incident_reference", "status": "acknowledged" } @@ -114,6 +114,7 @@ jobs: "created_at": "${{ fromJson(steps.acknowledge_incident.outputs.response).incidents[0].created_at }}", "updated_at": "${{ fromJson(steps.acknowledge_incident.outputs.response).incidents[0].updated_at }}" } + relations: "${{ toJson(fromJson(inputs.port_context).relations) }}" clientId: ${{ secrets.PORT_CLIENT_ID }} clientSecret: ${{ secrets.PORT_CLIENT_SECRET }} baseUrl: https://api.getport.io @@ -187,11 +188,10 @@ Create a new self service action using the following JSON configuration. "repo": "", "workflow": "acknowledge-incidents.yaml", "workflowInputs": { - "{{if (.inputs | has(\"ref\")) then \"ref\" else null end}}": "{{.inputs.\"ref\"}}", - "{{if (.inputs | has(\"from\")) then \"from\" else null end}}": "{{.inputs.\"from\"}}", + "from": "{{.inputs.\"from\"}}", "port_context": { "blueprint": "{{.action.blueprint}}", - "entity": "{{.entity}}", + "entity": "{{.entity.identifier}}", "run_id": "{{.run.id}}" } }, diff --git a/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/change-on-call-user.md b/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/change-on-call-user.md index 80200f2a9..d4c7bbed8 100644 --- a/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/change-on-call-user.md +++ b/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/change-on-call-user.md @@ -173,6 +173,7 @@ jobs: "description": "${{ fromJson(steps.new_schedule.outputs.response).schedule.description}}", "users": ${{ env.user_summaries }} } + relations: "${{ toJson(fromJson(inputs.port_context).relations) }}" clientId: ${{ secrets.PORT_CLIENT_ID }} clientSecret: ${{ secrets.PORT_CLIENT_SECRET }} baseUrl: https://api.getport.io @@ -250,15 +251,14 @@ Create a new self service action using the following JSON configuration. "type": "GITHUB", "org": "", "repo": "", - "workflow": "change-incident-owner.yaml", + "workflow": "change-on-call-user.yaml", "workflowInputs": { - "{{if (.inputs | has(\"ref\")) then \"ref\" else null end}}": "{{.inputs.\"ref\"}}", - "{{if (.inputs | has(\"start_time\")) then \"start_time\" else null end}}": "{{.inputs.\"start_time\"}}", - "{{if (.inputs | has(\"end_time\")) then \"end_time\" else null end}}": "{{.inputs.\"end_time\"}}", - "{{if (.inputs | has(\"new_on_call_user\")) then \"new_on_call_user\" else null end}}": "{{.inputs.\"new_on_call_user\"}}", + "start_time": "{{.inputs.\"start_time\"}}", + "end_time": "{{.inputs.\"end_time\"}}", + "new_on_call_user": "{{.inputs.\"new_on_call_user\"}}", "port_context": { "blueprint": "{{.action.blueprint}}", - "entity": "{{.entity}}", + "entity": "{{.entity.identifier}}", "run_id": "{{.run.id}}" } }, diff --git a/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/change-pagerduty-incident-owner.md b/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/change-pagerduty-incident-owner.md index 34afc07e9..e8952bba8 100644 --- a/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/change-pagerduty-incident-owner.md +++ b/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/change-pagerduty-incident-owner.md @@ -217,6 +217,7 @@ jobs: "created_at": "${{ fromJson(steps.change_owner.outputs.response).incident.created_at }}", "updated_at": "${{ fromJson(steps.change_owner.outputs.response).incident.updated_at }}" } + relations: "${{ toJson(fromJson(inputs.port_context).relations) }}" clientId: ${{ secrets.PORT_CLIENT_ID }} clientSecret: ${{ secrets.PORT_CLIENT_SECRET }} baseUrl: https://api.getport.io @@ -289,12 +290,11 @@ Create a new self service action using the following JSON configuration. "repo": "", "workflow": "change-incident-owner.yaml", "workflowInputs": { - "{{if (.inputs | has(\"ref\")) then \"ref\" else null end}}": "{{.inputs.\"ref\"}}", - "{{if (.inputs | has(\"new_owner_user_id\")) then \"new_owner_user_id\" else null end}}": "{{.inputs.\"new_owner_user_id\"}}", - "{{if (.inputs | has(\"from\")) then \"from\" else null end}}": "{{.inputs.\"from\"}}", + "new_owner": "{{.inputs.\"new_owner\"}}", + "from": "{{.inputs.\"from\"}}", "port_context": { "blueprint": "{{.action.blueprint}}", - "entity": "{{.entity}}", + "entity": "{{.entity.identifier}}", "run_id": "{{.run.id}}" } }, diff --git a/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/create-pagerduty-service.md b/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/create-pagerduty-service.md index ae3e5ee0e..e8ce03a1e 100644 --- a/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/create-pagerduty-service.md +++ b/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/create-pagerduty-service.md @@ -69,11 +69,26 @@ jobs: "service": { "name": "${{ github.event.inputs.name }}", "description": "${{ github.event.inputs.description }}", - "escalation_policy": ${{ github.event.inputs.escalation_policy }} + "status": "active", + "escalation_policy": { + "id": "${{ github.event.inputs.escalation_policy }}", + "type": "escalation_policy_reference" + } + } } - } - - - name: Create a log message + + - name: Log Create Service Request Failure + if: failure() + uses: port-labs/port-github-action@v1 + with: + clientId: ${{ secrets.PORT_CLIENT_ID }} + clientSecret: ${{ secrets.PORT_CLIENT_SECRET }} + baseUrl: https://api.getport.io + operation: PATCH_RUN + runId: ${{fromJson(inputs.port_context).run_id}} + logMessage: "Request to create service failed ..." + + - name: Log Request Success uses: port-labs/port-github-action@v1 with: clientId: ${{ secrets.PORT_CLIENT_ID }} @@ -83,17 +98,37 @@ jobs: runId: ${{fromJson(inputs.port_context).run_id}} logMessage: | PagerDuty service created! ✅ - Requesting for oncalls + Requesting for on-calls - - name: Request for oncalls for escalation_policy + - name: Request for oncalls for Escalation Policy id: fetch_oncalls uses: fjogeleit/http-request-action@v1 with: - url: 'https://api.pagerduty.com/oncalls?include[]=users&escalation_policy_ids[]=${{ fromJson(github.event.inputs.escalation_policy).id }}' + url: 'https://api.pagerduty.com/oncalls?include[]=users&escalation_policy_ids[]=${{ inputs.escalation_policy }}' method: 'GET' customHeaders: '{"Content-Type": "application/json", "Accept": "application/json", "Authorization": "Token token=${{ secrets.PAGERDUTY_API_KEY }}"}' - - name: Create a log message + - name: Extract User Emails + if: steps.fetch_oncalls.outcome == 'success' + id: extract_user_emails + run: | + echo "Extracting user emails..." + EMAILS=$(echo '${{ steps.fetch_oncalls.outputs.response }}' | jq -c '[.oncalls[].user.email]') + echo "Extracted emails: $EMAILS" + echo "user_emails=${EMAILS}" >> $GITHUB_ENV + + - name: Log Fetch Oncalls Request Failure + if: steps.fetch_oncalls.outcome == 'failure' + uses: port-labs/port-github-action@v1 + with: + clientId: ${{ secrets.PORT_CLIENT_ID }} + clientSecret: ${{ secrets.PORT_CLIENT_SECRET }} + baseUrl: https://api.getport.io + operation: PATCH_RUN + runId: ${{fromJson(inputs.port_context).run_id}} + logMessage: Failed to fetch on-calls ❌ + + - name: Log Before Upserting Entity uses: port-labs/port-github-action@v1 with: clientId: ${{ secrets.PORT_CLIENT_ID }} @@ -108,24 +143,23 @@ jobs: uses: port-labs/port-github-action@v1 with: identifier: "${{ fromJson(steps.create_service_request.outputs.response).service.id }}" - title: "${{ fromJson(steps.create_service_request.outputs.response).service.summary }}" - team: "[]" + title: "${{ fromJson(steps.create_service_request.outputs.response).service.summary }}" icon: pagerduty - blueprint: ${{fromJson(inputs.port_context).blueprint}} + blueprint: "${{fromJson(inputs.port_context).blueprint}}" properties: |- { "status": "${{ fromJson(steps.create_service_request.outputs.response).service.status }}", "url": "${{ fromJson(steps.create_service_request.outputs.response).service.html_url }}", - "oncall": "${{ fromJson(steps.fetch_oncalls).oncalls }}" + "oncall": ${{ env.user_emails }} } - relations: "{}" + relations: "${{ toJson(fromJson(inputs.port_context).relations) }}" clientId: ${{ secrets.PORT_CLIENT_ID }} clientSecret: ${{ secrets.PORT_CLIENT_SECRET }} baseUrl: https://api.getport.io operation: UPSERT runId: ${{fromJson(inputs.port_context).run_id}} - - name: Create a log message + - name: Log After Upserting Entity uses: port-labs/port-github-action@v1 with: clientId: ${{ secrets.PORT_CLIENT_ID }} @@ -134,7 +168,7 @@ jobs: operation: PATCH_RUN runId: ${{fromJson(inputs.port_context).run_id}} logMessage: | - Upsert was successful ✅ + Upserting was successful ✅ ``` @@ -175,7 +209,7 @@ Create a new self service action using the following JSON configuration. "description": "PagerDuty Escalation Policy ID to apply", "icon": "pagerduty", "type": "string" - }, + } }, "required": [ "name", @@ -195,13 +229,12 @@ Create a new self service action using the following JSON configuration. "repo": "", "workflow": "create-a-service.yaml", "workflowInputs": { - "{{if (.inputs | has(\"ref\")) then \"ref\" else null end}}": "{{.inputs.\"ref\"}}", - "{{if (.inputs | has(\"name\")) then \"name\" else null end}}": "{{.inputs.\"name\"}}", - "{{if (.inputs | has(\"description\")) then \"description\" else null end}}": "{{.inputs.\"description\"}}", - "{{if (.inputs | has(\"escalation_policy\")) then \"escalation_policy\" else null end}}": "{{.inputs.\"escalation_policy\"}}", + "name": "{{.inputs.\"name\"}}", + "description": "{{.inputs.\"description\"}}", + "escalation_policy": "{{.inputs.\"escalation_policy\"}}", "port_context": { "blueprint": "{{.action.blueprint}}", - "entity": "{{.entity}}", + "entity": "{{.entity.identifier}}", "run_id": "{{.run.id}}" } }, diff --git a/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/escalate-an-incident.md b/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/escalate-an-incident.md index 6842af91d..a5b04cf2e 100644 --- a/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/escalate-an-incident.md +++ b/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/escalate-an-incident.md @@ -72,7 +72,7 @@ jobs: id: escalate_incident uses: fjogeleit/http-request-action@v1 with: - url: 'https://api.pagerduty.com/incidents/${{inputs.entity_identifier}}' + url: 'https://api.pagerduty.com/incidents/${{fromJson(inputs.port_context).entity}}' method: 'PUT' customHeaders: '{"Content-Type": "application/json", "Accept": "application/vnd.pagerduty+json;version=2", "Authorization": "Token token=${{ secrets.PAGERDUTY_API_KEY }}", "From": "${{ github.event.inputs.from }}"}' data: >- @@ -109,6 +109,7 @@ jobs: logMessage: "Reporting the escalated incident back to Port ..." - name: Upsert pagerduty entity to Port + id: upsert_entity uses: port-labs/port-github-action@v1 with: identifier: ${{inputs.entity_identifier}} @@ -124,6 +125,7 @@ jobs: "created_at": "${{ fromJson(steps.escalate_incident.outputs.response).incident.created_at }}", "updated_at": "${{ fromJson(steps.escalate_incident.outputs.response).incident.updated_at }}" } + relations: "${{ toJson(fromJson(inputs.port_context).relations) }}" clientId: ${{ secrets.PORT_CLIENT_ID }} clientSecret: ${{ secrets.PORT_CLIENT_SECRET }} baseUrl: https://api.getport.io @@ -131,7 +133,7 @@ jobs: runId: ${{fromJson(inputs.port_context).run_id}} - name: Inform Entity upsert failure - if: failure() + if: steps.upsert_entity.outcome == 'failure' uses: port-labs/port-github-action@v1 with: clientId: ${{ secrets.PORT_CLIENT_ID }} @@ -141,7 +143,7 @@ jobs: runId: ${{fromJson(inputs.port_context).run_id}} logMessage: "Failed to report the escalated incident back to Port ..." - - name: Inform completion of PagerDuty escalation process into Port + - name: Inform completion of PagerDuty incident escalation uses: port-labs/port-github-action@v1 with: clientId: ${{ secrets.PORT_CLIENT_ID }} @@ -221,13 +223,12 @@ Create a new self service action using the following JSON configuration. "repo": "", "workflow": "ecalate-an-incident.yaml", "workflowInputs": { - "{{if (.inputs | has(\"ref\")) then \"ref\" else null end}}": "{{.inputs.\"ref\"}}", - "{{if (.inputs | has(\"escalation_policy_id\")) then \"escalation_policy_id\" else null end}}": "{{.inputs.\"escalation_policy_id\"}}", - "{{if (.inputs | has(\"urgency\")) then \"urgency\" else null end}}": "{{.inputs.\"urgency\"}}", - "{{if (.inputs | has(\"from\")) then \"from\" else null end}}": "{{.inputs.\"from\"}}", + "escalation_policy_id": "{{.inputs.\"escalation_policy_id\"}}", + "urgency": "{{.inputs.\"urgency\"}}", + "from": "{{.inputs.\"from\"}}", "port_context": { "blueprint": "{{.action.blueprint}}", - "entity": "{{.entity}}", + "entity": "{{.entity.identifier}}", "run_id": "{{.run.id}}" } }, diff --git a/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/resolve-incident.md b/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/resolve-incident.md index db8705d26..c7ab8fbb4 100644 --- a/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/resolve-incident.md +++ b/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/resolve-incident.md @@ -71,7 +71,7 @@ jobs: { "incidents": [ { - "id": "${{ fromJson(inputs.port_payload).port_context.entity }}", + "id": "${{fromJson(inputs.port_context).entity}}", "type": "incident_reference", "status": "resolved" } @@ -114,6 +114,7 @@ jobs: "created_at": "${{ fromJson(steps.resolve_incident.outputs.response).incidents[0].created_at }}", "updated_at": "${{ fromJson(steps.resolve_incident.outputs.response).incidents[0].updated_at }}" } + relations: "${{ toJson(fromJson(inputs.port_context).relations) }}" clientId: ${{ secrets.PORT_CLIENT_ID }} clientSecret: ${{ secrets.PORT_CLIENT_SECRET }} baseUrl: https://api.getport.io @@ -173,12 +174,12 @@ Create a new self service action using the following JSON configuration. "repo": "", "workflow": "resolve-incident.yaml", "workflowInputs": { - "{{if (.inputs | has(\"ref\")) then \"ref\" else null end}}": "{{.inputs.\"ref\"}}", - "{{if (.inputs | has(\"from\")) then \"from\" else null end}}": "{{.inputs.\"from\"}}", + "from": "{{.inputs.\"from\"}}", "port_context": { "blueprint": "{{.action.blueprint}}", - "entity": "{{.entity}}", - "run_id": "{{.run.id}}" + "entity": "{{.entity.identifier}}", + "run_id": "{{.run.id}}", + "relations": "{{.entity.relations}}" } }, "reportWorkflowStatus": true diff --git a/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/trigger-pagerduty-incident.md b/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/trigger-pagerduty-incident.md index 7d7979210..037a311a6 100644 --- a/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/trigger-pagerduty-incident.md +++ b/docs/create-self-service-experiences/setup-backend/github-workflow/examples/PagerDuty/trigger-pagerduty-incident.md @@ -55,8 +55,7 @@ on: jobs: trigger-incident: runs-on: ubuntu-latest - steps: - + steps: - name: Inform starting of PagerDuty trigger uses: port-labs/port-github-action@v1 with: @@ -66,6 +65,7 @@ jobs: runId: ${{fromJson(inputs.port_context).run_id}} logMessage: | About to trigger PagerDuty incident.. ⛴️ + - name: Send Event to PagerDuty id: trigger uses: fjogeleit/http-request-action@v1 @@ -76,14 +76,68 @@ jobs: data: >- { "payload": { - "summary": ${{ github.event.inputs.summary }}, - "source": ${{ github.event.inputs.source }}, - "severity": ${{ github.event.inputs.severity }}, + "summary": "${{ github.event.inputs.summary }}", + "source": "${{ github.event.inputs.source }}", + "severity": "${{ github.event.inputs.severity }}" }, "event_action": "${{ github.event.inputs.event_action }}", "routing_key": "${{ github.event.inputs.routing_key }}" } - - name: Create a log message + - name: Get PagerDuty Incident Details + id: get_incident + uses: fjogeleit/http-request-action@v1 + with: + url: 'https://api.pagerduty.com/incidents/${{fromJson(inputs.port_context).entity}}' + method: 'GET' + customHeaders: '{"Content-Type": "application/json", "Accept": "application/vnd.pagerduty+json;version=2", "Authorization": "Token token=${{ secrets.PAGERDUTY_API_KEY }}"}' + + - name: Log Before Upserting Entity + uses: port-labs/port-github-action@v1 + with: + clientId: ${{ secrets.PORT_CLIENT_ID }} + clientSecret: ${{ secrets.PORT_CLIENT_SECRET }} + baseUrl: https://api.getport.io + operation: PATCH_RUN + runId: ${{fromJson(inputs.port_context).run_id}} + logMessage: "Reporting the updated incident back to port ..." + + - name: UPSERT Entity + uses: port-labs/port-github-action@v1 + with: + identifier: "${{ fromJson(steps.get_incident.outputs.response).incident.id }}" + title: "${{ fromJson(steps.get_incident.outputs.response).incident.title }}" + team: "[]" + icon: "pagerduty" + blueprint: "${{fromJson(inputs.port_context).blueprint}}" + properties: |- + { + "status": "${{ fromJson(steps.get_incident.outputs.response).incident.status }}", + "url": "${{ fromJson(steps.get_incident.outputs.response).incident.self }}", + "urgency": "${{ fromJson(steps.get_incident.outputs.response).incident.urgency }}", + "responder": "${{ fromJson(steps.get_incident.outputs.response).incident.assignments[0].assignee.summary }}", + "escalation_policy": "${{ fromJson(steps.get_incident.outputs.response).incident.escalation_policy.summary }}", + "created_at": "${{ fromJson(steps.get_incident.outputs.response).incident.created_at }}", + "updated_at": "${{ fromJson(steps.get_incident.outputs.response).incident.updated_at }}" + } + relations: "${{ toJson(fromJson(inputs.port_context).relations) }}" + clientId: ${{ secrets.PORT_CLIENT_ID }} + clientSecret: ${{ secrets.PORT_CLIENT_SECRET }} + baseUrl: https://api.getport.io + operation: UPSERT + runId: ${{fromJson(inputs.port_context).run_id}} + + - name: Inform Entity upsert failure + if: steps.upsert_entity.outcome == 'failure' + uses: port-labs/port-github-action@v1 + with: + clientId: ${{ secrets.PORT_CLIENT_ID }} + clientSecret: ${{ secrets.PORT_CLIENT_SECRET }} + baseUrl: https://api.getport.io + operation: PATCH_RUN + runId: ${{fromJson(inputs.port_context).run_id}} + logMessage: "Failed to report the triggered incident back to Port ..." + + - name: Log After Upserting Entity id: log-response uses: port-labs/port-github-action@v1 with: @@ -94,7 +148,6 @@ jobs: runId: ${{fromJson(inputs.port_context).run_id}} logMessage: | PagerDuty incident triggered! ✅ - "The incident id is: ${{ steps.trigger.outputs}}" ``` @@ -146,7 +199,7 @@ Create a new self service action using the following JSON configuration. "title": "Summary", "icon": "pagerduty", "description": "A brief text summary of the event, used to generate the summaries/titles of any associated alerts. The maximum permitted length of this property is 1024 characters.", - "minLength": 1024 + "maxLength": 1024 }, "source": { "type": "string", @@ -197,16 +250,16 @@ Create a new self service action using the following JSON configuration. "repo": "", "workflow": "trigger-pagerduty-incident.yaml", "workflowInputs": { - "{{if (.inputs | has(\"ref\")) then \"ref\" else null end}}": "{{.inputs.\"ref\"}}", - "{{if (.inputs | has(\"summary\")) then \"summary\" else null end}}": "{{.inputs.\"summary\"}}", - "{{if (.inputs | has(\"source\")) then \"source\" else null end}}": "{{.inputs.\"source\"}}", - "{{if (.inputs | has(\"severity\")) then \"severity\" else null end}}": "{{.inputs.\"severity\"}}", - "{{if (.inputs | has(\"event_action\")) then \"event_action\" else null end}}": "{{.inputs.\"event_action\"}}", - "{{if (.inputs | has(\"routing_key\")) then \"routing_key\" else null end}}": "{{.inputs.\"routing_key\"}}", + "summary": "{{.inputs.\"summary\"}}", + "source": "{{.inputs.\"source\"}}", + "severity": "{{.inputs.\"severity\"}}", + "event_action": "{{.inputs.\"event_action\"}}", + "routing_key": "{{.inputs.\"routing_key\"}}", "port_context": { "blueprint": "{{.action.blueprint}}", - "entity": "{{.entity}}", - "run_id": "{{.run.id}}" + "entity": "{{.entity.identifier}}", + "run_id": "{{.run.id}}", + "relations": "{{.entity.relations}}" } }, "reportWorkflowStatus": true