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.3 KB
Raw Blame
import { createAction } from '@activepieces/pieces-framework';
import { githubAuth } from '../../auth';
import { githubApiCall } from '../../common';
import { HttpMethod } from '@activepieces/pieces-common';
import { ownerProp, repoProp, githubError } from './common';
import { repositoryBodyOutputSchema } from '../../output-schemas';

export const githubGetRepositoryAction = createAction({
  auth: githubAuth,
  name: 'get_repository',
  classification: 'READ',
  displayName: 'Get Repository (Agent)',
  description: 'Fetches metadata for a single repository.',
  audience: 'ai',
  aiMetadata: {
    description:
      'Fetches a single repository (GET /repos/{owner}/{repo}) including its default_branch, visibility, and your permissions. Use to discover the default branch before file or branch operations. Read-only and idempotent.',
    idempotent: true,
  },
  props: {
    owner: ownerProp,
    repo: repoProp,
  },
  outputSchema: repositoryBodyOutputSchema,
  async run({ auth, propsValue }) {
    const { owner, repo } = propsValue;
    try {
      const response = await githubApiCall({
        auth,
        method: HttpMethod.GET,
        resourceUri: `/repos/${owner}/${repo}`,
      });
      return response.body;
    } catch (error: any) {
      throw githubError(error, `Repository ${owner}/${repo}`);
    }
  },
});