Files
simstudioai--sim/apps/sim/triggers/github/pr_merged.ts
T
wehub-resource-sync d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

423 lines
11 KiB
TypeScript

import { GithubIcon } from '@/components/icons'
import type { TriggerConfig } from '@/triggers/types'
export const githubPRMergedTrigger: TriggerConfig = {
id: 'github_pr_merged',
name: 'GitHub PR Merged',
provider: 'github',
description: 'Trigger workflow when a pull request is successfully merged in a GitHub repository',
version: '1.0.0',
icon: GithubIcon,
subBlocks: [
{
id: 'webhookUrlDisplay',
title: 'Webhook URL',
type: 'short-input',
readOnly: true,
showCopyButton: true,
useWebhookUrl: true,
placeholder: 'Webhook URL will be generated',
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'github_pr_merged',
},
},
{
id: 'contentType',
title: 'Content Type',
type: 'dropdown',
options: [
{ label: 'application/json', id: 'application/json' },
{
label: 'application/x-www-form-urlencoded',
id: 'application/x-www-form-urlencoded',
},
],
defaultValue: 'application/json',
description: 'Format GitHub will use when sending the webhook payload.',
required: true,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'github_pr_merged',
},
},
{
id: 'webhookSecret',
title: 'Webhook Secret',
type: 'short-input',
placeholder: 'Generate or enter a strong secret',
description: 'Validates that webhook deliveries originate from GitHub.',
password: true,
required: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'github_pr_merged',
},
},
{
id: 'sslVerification',
title: 'SSL Verification',
type: 'dropdown',
options: [
{ label: 'Enabled', id: 'enabled' },
{ label: 'Disabled', id: 'disabled' },
],
defaultValue: 'enabled',
description: 'GitHub verifies SSL certificates when delivering webhooks.',
required: true,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'github_pr_merged',
},
},
{
id: 'triggerInstructions',
title: 'Setup Instructions',
hideFromPreview: true,
type: 'text',
defaultValue: [
'Go to your GitHub Repository > Settings > Webhooks.',
'Click "Add webhook".',
'Paste the <strong>Webhook URL</strong> above into the "Payload URL" field.',
'Select your chosen Content Type from the dropdown.',
'Enter the <strong>Webhook Secret</strong> into the "Secret" field if you\'ve configured one.',
'Set SSL verification according to your selection.',
'Select "Let me select individual events" and check <strong>pull_request</strong>. Note: Merged PRs have <strong>action=\'closed\'</strong> AND <strong>merged=true</strong>.',
'Ensure "Active" is checked and click "Add webhook".',
]
.map(
(instruction, index) =>
`<div class="mb-3"><strong>${index + 1}.</strong> ${instruction}</div>`
)
.join(''),
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'github_pr_merged',
},
},
],
outputs: {
event_type: {
type: 'string',
description: 'GitHub event type from X-GitHub-Event header (e.g., pull_request)',
},
action: {
type: 'string',
description: 'Action performed (opened, closed, synchronize, reopened, edited, etc.)',
},
number: {
type: 'number',
description: 'Pull request number',
},
pull_request: {
id: {
type: 'number',
description: 'Pull request ID',
},
node_id: {
type: 'string',
description: 'Pull request node ID',
},
number: {
type: 'number',
description: 'Pull request number',
},
title: {
type: 'string',
description: 'Pull request title',
},
body: {
type: 'string',
description: 'Pull request description',
},
state: {
type: 'string',
description: 'Pull request state (open, closed)',
},
merged: {
type: 'boolean',
description: 'Whether the PR was merged',
},
merged_at: {
type: 'string',
description: 'Timestamp when PR was merged',
},
merged_by: {
login: {
type: 'string',
description: 'Username',
},
id: {
type: 'number',
description: 'User ID',
},
node_id: {
type: 'string',
description: 'User node ID',
},
avatar_url: {
type: 'string',
description: 'Avatar URL',
},
html_url: {
type: 'string',
description: 'Profile URL',
},
user_type: {
type: 'string',
description: 'User type (User, Bot, Organization)',
},
},
draft: {
type: 'boolean',
description: 'Whether the PR is a draft',
},
html_url: {
type: 'string',
description: 'Pull request HTML URL',
},
diff_url: {
type: 'string',
description: 'Pull request diff URL',
},
patch_url: {
type: 'string',
description: 'Pull request patch URL',
},
user: {
login: {
type: 'string',
description: 'Username',
},
id: {
type: 'number',
description: 'User ID',
},
node_id: {
type: 'string',
description: 'User node ID',
},
avatar_url: {
type: 'string',
description: 'Avatar URL',
},
html_url: {
type: 'string',
description: 'Profile URL',
},
user_type: {
type: 'string',
description: 'User type (User, Bot, Organization)',
},
},
head: {
ref: {
type: 'string',
description: 'Source branch name',
},
sha: {
type: 'string',
description: 'Source branch commit SHA',
},
repo: {
name: {
type: 'string',
description: 'Source repository name',
},
full_name: {
type: 'string',
description: 'Source repository full name',
},
},
},
base: {
ref: {
type: 'string',
description: 'Target branch name',
},
sha: {
type: 'string',
description: 'Target branch commit SHA',
},
repo: {
name: {
type: 'string',
description: 'Target repository name',
},
full_name: {
type: 'string',
description: 'Target repository full name',
},
},
},
additions: {
type: 'number',
description: 'Number of lines added',
},
deletions: {
type: 'number',
description: 'Number of lines deleted',
},
changed_files: {
type: 'number',
description: 'Number of files changed',
},
labels: {
type: 'array',
description: 'Array of label objects',
},
assignees: {
type: 'array',
description: 'Array of assigned users',
},
requested_reviewers: {
type: 'array',
description: 'Array of requested reviewers',
},
created_at: {
type: 'string',
description: 'Pull request creation timestamp',
},
updated_at: {
type: 'string',
description: 'Pull request last update timestamp',
},
closed_at: {
type: 'string',
description: 'Pull request closed timestamp',
},
},
repository: {
id: {
type: 'number',
description: 'Repository ID',
},
node_id: {
type: 'string',
description: 'Repository node ID',
},
name: {
type: 'string',
description: 'Repository name',
},
full_name: {
type: 'string',
description: 'Repository full name (owner/repo)',
},
private: {
type: 'boolean',
description: 'Whether the repository is private',
},
html_url: {
type: 'string',
description: 'Repository HTML URL',
},
repo_description: {
type: 'string',
description: 'Repository description',
},
fork: {
type: 'boolean',
description: 'Whether the repository is a fork',
},
url: {
type: 'string',
description: 'Repository API URL',
},
homepage: {
type: 'string',
description: 'Repository homepage URL',
},
size: {
type: 'number',
description: 'Repository size in KB',
},
stargazers_count: {
type: 'number',
description: 'Number of stars',
},
watchers_count: {
type: 'number',
description: 'Number of watchers',
},
language: {
type: 'string',
description: 'Primary programming language',
},
forks_count: {
type: 'number',
description: 'Number of forks',
},
open_issues_count: {
type: 'number',
description: 'Number of open issues',
},
default_branch: {
type: 'string',
description: 'Default branch name',
},
owner: {
login: {
type: 'string',
description: 'Owner username',
},
id: {
type: 'number',
description: 'Owner ID',
},
avatar_url: {
type: 'string',
description: 'Owner avatar URL',
},
html_url: {
type: 'string',
description: 'Owner profile URL',
},
},
},
sender: {
login: {
type: 'string',
description: 'Username',
},
id: {
type: 'number',
description: 'User ID',
},
node_id: {
type: 'string',
description: 'User node ID',
},
avatar_url: {
type: 'string',
description: 'Avatar URL',
},
html_url: {
type: 'string',
description: 'Profile URL',
},
user_type: {
type: 'string',
description: 'User type (User, Bot, Organization)',
},
},
},
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-GitHub-Event': 'pull_request',
'X-GitHub-Delivery': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
'X-Hub-Signature-256': 'sha256=...',
},
},
}