Publish to GitHub

Action ID: publish:github
NPM Package:

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

Description

Initializes a git repository of contents in workspace and publishes it to GitHub.

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
homepagestringRepository Homepage
hasIssuesbooleanEnable issues for the repository. The default value is `true`
subscribeboolean-
sourcePathstringPath within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.
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
defaultBranchstring-
gitAuthorNamestringSets the default author name for the commit. The default value is `Scaffolder`
repoVariablesobjectVariables attached to the repository
allowAutoMergebooleanAllow individual PRs to merge automatically when all merge requirements are met. The default value is `false`
gitAuthorEmailstring-
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
gitCommitMessagestringSets the commit message on the repository. The default value is `initial commit`
allowUpdateBranchbooleanAllow branch to be updated. The default value is `false`
oidcCustomizationobject-
deleteBranchOnMergebooleanDelete the branch after merging the PR. The default value is `false`
dismissStaleReviewsbooleanNew reviewable commits pushed to a matching branch will dismiss pull request review approvals.
protectDefaultBranchbooleanProtect the default branch after creating the repository. The default value is `true`
protectEnforceAdminsbooleanEnforce admins to adhere to default branch protection. The default value is `true`
requiredCommitSigningboolean-
requiredLinearHistoryboolean-
squashMergeCommitTitlestring-
requireCodeOwnerReviewsbooleanRequire an approved review in PR including files with a designated Code Owner
requireLastPushApprovalbooleanWhether the most recent push to a PR must be approved by someone other than the person who pushed it. The default value is `false`
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
commitHashstringThe git commit hash of the initial commit
repoContentsUrlstringA URL to the root of the repository

Usage Examples

Publish a private repo to a GitHub organization with branch protection

Publishes the generated service to a private repository under an organization, sets the default branch, and enables basic branch protection. Use this after fetch:template and follow with catalog:register.

Copy
steps:
  - id: fetch-base
    action: fetch:template
    input:
      url: https://github.com/backstage/software-templates/tree/main/scaffolder-templates/service-skeleton
      targetPath: .
      values:
        name: ${{ parameters.name }}
        owner: ${{ parameters.owner }}
        description: ${{ parameters.description }}

  - id: publish
    action: publish:github
    input:
      repoUrl: github.com?owner=acme-org&repo=${{ parameters.repoName }}
      repoVisibility: private
      description: Order processing service for Acme
      defaultBranch: main
      protectDefaultBranch: true
      requireCodeOwnerReviews: true
      requiredApprovingReviewCount: 1
      topics:
        - orders
        - node
        - backstage

  - id: register
    action: catalog:register
    input:
      catalogInfoUrl: ${{ steps.publish.output.repoContentsUrl }}/catalog-info.yaml

Publish to GitHub Enterprise with internal visibility and a nondefault branch

Publishes to a GitHub Enterprise host with internal visibility and uses a develop default branch. Use this when your organization hosts GitHub on a custom domain and wants repos visible to the enterprise only.

Copy
steps:
  - id: fetch-skeleton
    action: fetch:template
    input:
      url: https://github.com/backstage/software-templates/tree/main/scaffolder-templates/library-skeleton
      targetPath: .
      values:
        name: ${{ parameters.name }}
        owner: ${{ parameters.owner }}
        description: ${{ parameters.description }}

  - id: publish
    action: publish:github
    input:
      repoUrl: ghe.acme.internal?owner=platform-eng&repo=${{ parameters.repoName }}
      repoVisibility: internal
      description: Shared payments library for internal services
      defaultBranch: develop
      protectDefaultBranch: false
      requireCodeOwnerReviews: false
      topics:
        - payments
        - shared-lib
        - typescript

  - id: register
    action: catalog:register
    input:
      catalogInfoUrl: ${{ steps.publish.output.repoContentsUrl }}/catalog-info.yaml