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 { releaseBodyOutputSchema } from '../../output-schemas';

export const githubGetLatestReleaseAction = createAction({
  auth: githubAuth,
  name: 'get_latest_release',
  classification: 'READ',
  displayName: 'Get Latest Release (Agent)',
  description: 'Fetches the latest published release.',
  audience: 'ai',
  aiMetadata: {
    description:
      'Fetches the latest published release (GET /repos/{owner}/{repo}/releases/latest) — the most recent non-draft, non-prerelease release by date. Returns 404 if the repo has no published release. Read-only and idempotent.',
    idempotent: true,
  },
  props: {
    owner: ownerProp,
    repo: repoProp,
  },
  outputSchema: releaseBodyOutputSchema,
  async run({ auth, propsValue }) {
    const { owner, repo } = propsValue;
    try {
      const response = await githubApiCall({
        auth,
        method: HttpMethod.GET,
        resourceUri: `/repos/${owner}/${repo}/releases/latest`,
      });
      return response.body;
    } catch (error: any) {
      throw githubError(error, `Latest release in ${owner}/${repo}`);
    }
  },
});