Workflows / Github / installation_target

GitHub Installation Target Renamed Notification to Slack

Use the Github integration by MagicBell to setup a workflow when installation_target triggers in Github.

Connect Github to MagicBell to receive events and trigger workflows. This guide uses the MagicBell CLI.

Add the Github integration

Save your Github webhook signing secret in MagicBell. See GitHub webhooks.

magicbell integration save_github \
  --data '{"webhook_signing_secret":"your_secret_here"}'

Copy the ID from the response and use it to build your webhook URL:

https://api.magicbell.com/v2/integrations/github/webhooks/incoming/{id}

Setup the webhook

Add a workflow

Create a workflow that triggers automatically when Github sends this event.

Workflow key

Use this key to trigger the workflow when Github sends a installation_target event:

integration.github.installation_target

Filter by action: GitHub sends the event type in the header and the action in the payload body. Use an if condition to filter for the renamed action:

"if": "payload.action == 'renamed'"

Example workflow

Track when installation target accounts are renamed.

{
  "key": "integration.github.installation_target.renamed",
  "steps": [
    {
      "command": "broadcast",
      "input": {
        "action_url": "{{payload.installation.html_url}}",
        "content": "{{payload.target_type}} {{payload.changes.login.from}} was renamed to {{payload.account.login}}.",
        "overrides": {
          "providers": {
            "slack": {}
          }
        },
        "recipients": [
          {
            "external_id": "app-admins"
          }
        ],
        "title": "Installation target renamed"
      }
    }
  ]
}

Save with the CLI

Use the MagicBell CLI to save this workflow to your project. You can also use the Workflows API endpoint instead.

magicbell workflow save \
  --data '{"key":"integration.github.installation_target.renamed","steps":[{"command":"broadcast","input":{"action_url":"{{payload.installation.html_url}}","content":"{{payload.target_type}} {{payload.changes.login.from}} was renamed to {{payload.account.login}}.","overrides":{"providers":{"slack":{}}},"recipients":[{"external_id":"app-admins"}],"title":"Installation target renamed"}}]}'

Event payload

Sample payload for the installation_target event. Use liquid templates to access fields in your workflow.

{
  "account": {
    "avatar_url": "https://avatars.githubusercontent.com/u/111111?v=4",
    "gravatar_id": "",
    "html_url": "https://github.com/acme-new",
    "id": 111111,
    "login": "acme-new",
    "node_id": "MDEyOk9yZ2FuaXphdGlvbjExMTExMQ==",
    "site_admin": false,
    "type": "Organization",
    "url": "https://api.github.com/users/acme-new"
  },
  "action": "renamed",
  "changes": {
    "login": {
      "from": "acme"
    },
    "slug": {
      "from": "acme"
    }
  },
  "installation": {
    "account": {
      "avatar_url": "https://avatars.githubusercontent.com/u/111111?v=4",
      "html_url": "https://github.com/acme-new",
      "id": 111111,
      "login": "acme-new",
      "node_id": "MDEyOk9yZ2FuaXphdGlvbjExMTExMQ==",
      "type": "Organization"
    },
    "app_id": 98765,
    "app_slug": "my-github-app",
    "html_url": "https://github.com/organizations/acme-new/settings/installations/12345678",
    "id": 12345678,
    "repository_selection": "all"
  },
  "sender": {
    "avatar_url": "https://avatars.githubusercontent.com/u/234567?v=4",
    "html_url": "https://github.com/org-admin",
    "id": 234567,
    "login": "org-admin",
    "node_id": "MDQ6VXNlcjIzNDU2Nw==",
    "type": "User"
  },
  "target_type": "Organization"
}
View all Github workflows →