Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

2.2 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { githubAuth } from '../auth';
import { githubApiCall, githubCommon } from '../common';
import { HttpMethod } from '@activepieces/pieces-common';
import { issueActionOutputSchema } from '../output-schemas';

export const githubCreateIssueAction = createAction({
  auth: githubAuth,
  name: 'github_create_issue',
  classification: 'WRITE',
  displayName: 'Create Issue',
  description: 'Opens a new issue in a repository.',
  audience: 'human',
  aiMetadata: {
    description:
      'Opens a new issue in a GitHub repository with a title and optional body, labels, and assignees. Use to file a bug, task, or request in a specified repo. Not idempotent: each call creates a separate issue even with identical input.',
    idempotent: false,
  },
  propertyGroups: [
    {
      key: 'issue',
      display: 'section',
      label: 'Issue',
      icon: 'inbox',
      props: ['repository', 'title', 'description'],
    },
    {
      key: 'organize',
      display: 'section',
      label: 'Labels and people',
      icon: 'tag',
      props: ['labels', 'assignees'],
    },
  ],
  props: {
    repository: githubCommon.repositoryDropdown,
    title: Property.ShortText({
      displayName: 'Title',
      placeholder: 'Login page shows an error',
      required: true,
    }),
    description: Property.LongText({
      displayName: 'Description',
      description: 'Markdown is supported.',
      required: false,
    }),
    labels: githubCommon.labelDropDown(),
    assignees: githubCommon.assigneeDropDown(),
  },
  outputSchema: issueActionOutputSchema,
  async run({ auth, propsValue }) {
    const { title, assignees, labels, description } = propsValue;
    const { owner, repo } = propsValue.repository!;

    const issueFields: Record<string, any> = {
      title,
      body: description,
    };

    if (labels) {
      issueFields['labels'] = labels;
    }

    if (assignees) {
      issueFields['assignees'] = assignees;
    }

    const response = await githubApiCall({
      auth,
      method: HttpMethod.POST,
      resourceUri: `/repos/${owner}/${repo}/issues`,
      body: issueFields,
    });

    return response;
  },
});