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

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

export const githubAddLabelsToIssueAction = createAction({
  auth: githubAuth,
  name: 'add_labels_to_issue',
  classification: 'WRITE',
  displayName: 'Add Labels to Issue',
  description: 'Adds labels to an issue and keeps the ones it has.',
  audience: 'human',
  aiMetadata: {
    description:
      'Adds one or more labels to an existing issue (by number) in a repository, leaving any labels already on the issue in place. Use to tag or categorize an issue. Idempotent in effect: re-adding a label the issue already has does not duplicate it.',
    idempotent: true,
  },
  propertyGroups: [
    {
      key: 'issue',
      display: 'section',
      label: 'Issue',
      icon: 'inbox',
      props: ['repository', 'issue_number'],
    },
    {
      key: 'labels',
      display: 'section',
      label: 'Labels',
      icon: 'tag',
      props: ['labels'],
    },
  ],
  props: {
    repository: githubCommon.repositoryDropdown,
    issue_number: githubCommon.issueDropdown(true),
    labels: githubCommon.labelDropDown(true),
  },
  outputSchema: addLabelsToIssueActionOutputSchema,
  async run({ auth, propsValue }) {
    const { owner, repo } = propsValue.repository!;
    const issue_number = propsValue.issue_number;
    const labels = propsValue.labels;

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

    return response;
  },
});