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.5 KB
Raw Blame
import { createAction, Property } 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 { commitBodyOutputSchema } from '../../output-schemas';

export const githubGetCommitAction = createAction({
  auth: githubAuth,
  name: 'get_commit',
  classification: 'READ',
  displayName: 'Get Commit (Agent)',
  description: 'Fetches a single commit including its file changes.',
  audience: 'ai',
  aiMetadata: {
    description:
      'Fetches a single commit (GET /repos/{owner}/{repo}/commits/{ref}) by SHA, branch, or tag, including its files, stats, and parents. Resolve refs via List Commits or List Branches. Read-only and idempotent.',
    idempotent: true,
  },
  props: {
    owner: ownerProp,
    repo: repoProp,
    ref: Property.ShortText({
      displayName: 'Ref',
      description: 'Commit SHA, branch name, or tag. Resolve via List Commits.',
      required: true,
    }),
  },
  outputSchema: commitBodyOutputSchema,
  async run({ auth, propsValue }) {
    const { owner, repo, ref } = propsValue;
    try {
      const response = await githubApiCall({
        auth,
        method: HttpMethod.GET,
        resourceUri: `/repos/${owner}/${repo}/commits/${ref}`,
      });
      return response.body;
    } catch (error: any) {
      throw githubError(error, `Commit "${ref}" in ${owner}/${repo}`);
    }
  },
});