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

2.2 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { vercelAuth } from '../common/auth';
import { listDeployments, vercelApiCall } from '../common/client';
import { vercelProjectDropdown } from '../common/props';

export const getDeploymentStatus = createAction({
  auth: vercelAuth,
  name: 'get_deployment_status',
  classification: 'READ',
  displayName: 'Get Deployment Status',
  description: 'Retrieve a deployment and inspect its current status.',
  audience: 'both',
  aiMetadata: {
    description: 'Fetch a single Vercel deployment by ID and inspect its current state (e.g. building, ready, error), optionally including Git repository info. Use this to poll or check the outcome of a deployment. Requires the deployment ID, scoped to a chosen project. Read-only and idempotent.',
    idempotent: true,
  },
  props: {
    project: vercelProjectDropdown,
    deployment: Property.Dropdown({
      displayName: 'Deployment',
      description: 'Select the deployment to inspect.',
      required: true,
      auth: vercelAuth,
      refreshers: ['auth', 'project'],
      options: async ({ auth, project }) => {
        if (!auth || !project) {
          return { disabled: true, placeholder: 'Select a project first', options: [] };
        }
        const deployments = await listDeployments(auth, String(project));
        return {
          disabled: false,
          options: deployments.map((d) => ({
            label: d.url
              ? `${d.url} (${d.state ?? 'unknown'}${d.target ? ` · ${d.target}` : ''})`
              : d.name,
            value: d.uid,
          })),
        };
      },
    }),
    with_git_repo_info: Property.Checkbox({
      displayName: 'Include Git Repository Info',
      description: 'Adds gitRepo information when available.',
      required: false,
      defaultValue: true,
    }),
  },
  async run(context) {
    const { deployment, with_git_repo_info } = context.propsValue;

    return await vercelApiCall({
      method: HttpMethod.GET,
      path: `/v13/deployments/${encodeURIComponent(String(deployment))}`,
      auth: context.auth,
      query: {
        withGitRepoInfo: with_git_repo_info ? 'true' : undefined,
      },
    });
  },
});