Create GitHub Repository

Action ID: github:repo:create
NPM Package:

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

Description

Creates a GitHub repository.

Input Schema

PropertyTypeDescriptionRequired
tokenstringThe token to use for authorization to GitHub
accessstringSets an admin collaborator on the repository. Can either be a user reference different from `owner` in `repoUrl` or team reference, eg. `org/team-name`
topicsarrayAdds topics to the repository
hasWikibooleanEnable the wiki for the repository. The default value is `true`
repoUrlstringAccepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username
secretsobjectSecrets attached to the repository
autoInitboolean-
homepagestringRepository Homepage
hasIssuesbooleanEnable issues for the repository. The default value is `true`
subscribeboolean-
descriptionstringRepository Description
hasProjectsbooleanEnable projects for the repository. The default value is `true` unless the organization has disabled repository projects
restrictionsobject-
collaboratorsarrayProvide additional users or teams with permissions
repoVariablesobjectVariables attached to the repository
allowAutoMergebooleanAllow individual PRs to merge automatically when all merge requirements are met. The default value is `false`
repoVisibilitystring-
allowMergeCommitbooleanAllow merge commits. The default value is `true`
allowRebaseMergebooleanAllow rebase merges. The default value is `true`
allowSquashMergebooleanAllow squash merges. The default value is `true`
customPropertiesobjectCustom properties to be added to the repository (note, this only works for organization repositories). All values must be strings
allowUpdateBranchbooleanAllow branch to be updated. The default value is `false`
oidcCustomizationobject-
deleteBranchOnMergebooleanDelete the branch after merging the PR. The default value is `false`
requiredCommitSigningboolean-
requiredLinearHistoryboolean-
squashMergeCommitTitlestring-
requireCodeOwnerReviewsbooleanRequire an approved review in PR including files with a designated Code Owner
squashMergeCommitMessagestring-
bypassPullRequestAllowancesobject-
requireBranchesToBeUpToDatebooleanRequire branches to be up to date before merging. The default value is `true`
requiredStatusCheckContextsarrayThe list of status checks to require in order to merge into this branch
requiredApprovingReviewCountnumberSpecify the number of reviewers required to approve pull requests. Use a number between `1` and `6` or `0` to not require reviewers. Defaults to `1`.
requiredConversationResolutionbooleanRequires all conversations on code to be resolved before a pull request can be merged into this branch

Output Schema

PropertyTypeDescriptionRequired
remoteUrlstringA URL to the repository with the provider
repoContentsUrlstringA URL to the root of the repository

Usage Examples

Create a new repository in a GitHub organization and push generated code

Creates a repository in a GitHub organization using a repoUrl and then pushes the generated template code. Use this when your template needs a fresh repo before pushing code with github:repo:push.

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

  - id: create-repo
    action: github:repo:create
    input:
      repoUrl: github.com?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      description: ${{ parameters.description }}

  - id: push-initial-code
    action: github:repo:push
    input:
      repoUrl: github.com?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      sourcePath: .

Create a repository on GitHub Enterprise and register it in the catalog

Creates a repository on a GitHub Enterprise Server instance and then registers the service in the catalog. Use this when targeting an internal GHE host and you want to track the new component with catalog:register.

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

  - id: create-repo
    action: github:repo:create
    input:
      repoUrl: ghe.acme.corp?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      description: ${{ parameters.description }}

  - id: push-code
    action: github:repo:push
    input:
      repoUrl: ghe.acme.corp?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      sourcePath: .

  - id: register
    action: catalog:register
    input:
      catalogInfoUrl: https://ghe.acme.corp/${{ parameters.owner }}/${{ parameters.repoName }}/blob/main/catalog-info.yaml