Skip to content
This repository was archived by the owner on Jul 30, 2026. It is now read-only.
This repository was archived by the owner on Jul 30, 2026. It is now read-only.

Allow callers to specify additional parameters (summary, severity, group, class, component) #7

Open

Description

@JackFreelander

Would be nice to allow callers to pass additional parameters; I have a (local) branch for this (including updates to README) but don't have permission to push upstream.

// Run the action
try {
  const severityLevels = ['critical', 'error', 'warning', 'info'];
  const defaultSeverity = 'critical';

  const integrationKey = core.getInput('pagerduty-integration-key');
  const summary = core.getInput('pagerduty-summary') ?? `${context.repo.repo}: Error in "${context.workflow}" run by @${context.actor}`;
  const severityParam = core.getInput('pagerduty-severity');
  const severity = severityLevels.includes(severityParam) ? severityParam : defaultSeverity;

  let alert = {
    payload: {
      summary,
      timestamp: new Date().toISOString(),
      source: 'GitHub Actions',
      severity,
      custom_details: {
        run_details: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
        related_commits: context.payload.commits
          ? context.payload.commits.map((commit) => `${commit.message}: ${commit.url}`).join(', ')
          : 'No related commits',
      },
    },
    routing_key: integrationKey,
    event_action: 'trigger',
  };

  // See https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTgx-send-an-alert-event for endpoint documentation
  const componentParam = core.getInput('pagerduty-component');
  if (componentParam) {
    alert.component = componentParam;
  }

  const groupParam = core.getInput('pagerduty-group');
  if (groupParam) {
    alert.group = groupParam;
  }

  const classParam = core.getInput('pagerduty-class');
  if (classParam) {
    alert.class = classParam;
  }

  const dedupKey = core.getInput('pagerduty-dedup-key');
  if (dedupKey != '') {
    alert.dedup_key = dedupKey;
  }
  sendAlert(alert);
} catch (error) {
  core.setFailed(error.message);
}

Activity

  1. miparnisari commented on Apr 14, 2023

    @miparnisari
    Contributor

    I did something similar to this in my fork: https://github.com/miparnisari/action-pagerduty-alert. Feel free to send a PR to add more fields :)

  2. JohJonker commented on Nov 20, 2024

    @JohJonker
    Contributor

    Thanks for the input @JackFreelander and sorry for the slow response. Could you submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions