Create GitHub Webhook

Action ID: github:webhook
NPM Package:

@backstage/plugin-scaffolder-backend-module-github

Description

Creates webhook for a repository on GitHub.

Input Schema

PropertyTypeDescriptionRequired
tokenstringThe `GITHUB_TOKEN` to use for authorization to GitHub
activebooleanDetermines if notifications are sent when the webhook is triggered. Default: `true`
eventsany-
repoUrlstringAccepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username
webhookUrlstringThe URL to which the payloads will be delivered
contentTypestring-
insecureSslbooleanDetermines whether the SSL certificate of the host for url will be verified when delivering payloads. Default `false`
webhookSecretstringWebhook secret value. The default can be provided internally in action creation

Output Schema

No output schema defined for this action.

Usage Examples

Create a push webhook with a shared secret after publishing a new repo

Creates a webhook that triggers on push events and delivers JSON payloads to your build system. Use this right after fetching source with fetch:template and publishing the repo with publish:github.

Copy
steps:
  - id: fetchBase
    action: fetch:template
    input:
      url: ./skeleton
      targetPath: ./workspace
      values:
        name: ${{ parameters.repoName }}

  - id: publishRepo
    action: publish:github
    input:
      repoUrl: github.com?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      description: ${{ parameters.description }}
      repoVisibility: private
      defaultBranch: main

  - id: createWebhook
    action: github:webhook
    input:
      repoUrl: github.com?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      webhookUrl: https://hooks.example.com/github/${{ parameters.repoName }}
      webhookSecret: ${{ parameters.webhookSecret }}
      events:
        - push
      contentType: json

Webhook for pull request and issue triage with an explicit token

Creates a webhook for pull request and issue events using a provided GitHub token. Use this when your workflow needs a specific token rather than the default integration credentials, following fetch:template and publish:github.

Copy
steps:
  - id: fetchBase
    action: fetch:template
    input:
      url: ./template
      targetPath: .
      values:
        service: ${{ parameters.repoName }}

  - id: publishRepo
    action: publish:github
    input:
      repoUrl: github.com?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      repoVisibility: internal
      defaultBranch: main

  - id: triageWebhook
    action: github:webhook
    input:
      repoUrl: github.com?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      webhookUrl: https://triage.acme.io/webhooks/github
      events:
        - pull_request
        - issues
        - issue_comment
      contentType: json
      token: ${{ parameters.githubToken }}

GitHub Enterprise all events webhook with SSL verification disabled

Creates a webhook on a GitHub Enterprise instance that listens to all events and posts form-encoded payloads to an internal collector. Use this when testing against an internal endpoint with a self-signed certificate after publish:github.

Copy
steps:
  - id: publishRepo
    action: publish:github
    input:
      repoUrl: ghe.mycorp.internal?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      repoVisibility: private
      defaultBranch: main
      description: ${{ parameters.description }}

  - id: enterpriseWebhook
    action: github:webhook
    input:
      repoUrl: ghe.mycorp.internal?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      webhookUrl: https://collector.internal.local/hooks/github
      events:
        - "*"
      contentType: form
      insecureSsl: true
      webhookSecret: ${{ parameters.webhookSecret }}

Create an inactive webhook for release notifications to staging

Creates a webhook for release events but leaves it inactive for later activation. Use this to preconfigure staging integrations after fetch:template and publish:github.

Copy
steps:
  - id: fetchBase
    action: fetch:template
    input:
      url: ./template
      targetPath: .
      values:
        name: ${{ parameters.repoName }}

  - id: publishRepo
    action: publish:github
    input:
      repoUrl: github.com?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      repoVisibility: private
      defaultBranch: main

  - id: stagingReleaseWebhook
    action: github:webhook
    input:
      repoUrl: github.com?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      webhookUrl: https://staging-hooks.acme.io/github/releases
      events:
        - release
      contentType: json
      active: false

Create two webhooks for CI and chat notifications on the same repo

Creates separate webhooks for CI and chat systems with different event sets. Use this to wire multiple downstream consumers immediately after publish:github.

Copy
steps:
  - id: publishRepo
    action: publish:github
    input:
      repoUrl: github.com?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      repoVisibility: private
      defaultBranch: main
      description: ${{ parameters.description }}

  - id: ciWebhook
    action: github:webhook
    input:
      repoUrl: github.com?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      webhookUrl: https://ci.example.com/api/webhooks/github
      webhookSecret: ${{ parameters.webhookSecret }}
      events:
        - push
        - pull_request
      contentType: json

  - id: chatWebhook
    action: github:webhook
    input:
      repoUrl: github.com?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      webhookUrl: https://chatops.example.com/hooks/github
      events:
        - issue_comment
        - pull_request_review_comment
      contentType: json