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
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { createAction, Property } from '@activepieces/pieces-framework';
import { githubAuth } from '../auth';
import { githubApiCall, githubCommon } from '../common';
import { HttpError, HttpMethod } from '@activepieces/pieces-common';
import { findBranchActionOutputSchema } from '../output-schemas';
export const githubFindBranchAction = createAction({
auth: githubAuth,
name: 'find_branch',
classification: 'READ',
displayName: 'Find Branch',
description: 'Looks up a branch by its exact name.',
audience: 'both',
aiMetadata: {
description:
'Looks up a branch in a repository by its exact name and reports whether it exists along with its details. Use to check for a branch or fetch its tip before acting on it; a missing branch is reported as not-found rather than raising an error. Read-only and idempotent.',
idempotent: true,
},
props: {
repository: githubCommon.repositoryDropdown,
branch: Property.ShortText({
displayName: 'Branch Name',
description: 'Case-sensitive.',
placeholder: 'main',
required: true,
}),
},
propertyGroups: [
{
key: 'branch',
display: 'section',
label: 'Branch',
icon: 'code',
props: ['repository', 'branch'],
},
],
outputSchema: findBranchActionOutputSchema,
async run({ auth, propsValue }) {
const { owner, repo } = propsValue.repository!;
const branchName = propsValue.branch;
try {
const response = await githubApiCall({
auth,
method: HttpMethod.GET,
resourceUri: `/repos/${owner}/${repo}/branches/${branchName}`,
});
return {
found: true,
result: response.body,
};
} catch (e) {
if (e instanceof HttpError && e.response.status === 404) {
return {
found: false,
result: {},
};
}
throw e;
}
},
});