Initializes a git repository of contents in workspace and publishes it to GitHub.
Input Schema
| Property | Type | Description | Required |
|---|---|---|---|
| token | string | The token to use for authorization to GitHub | |
| repoUrl | string | Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username | |
| sourcePath | string | Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository. | |
| restrictions | object | - | |
| defaultBranch | string | - | |
| gitAuthorName | string | Sets the default author name for the commit. The default value is `Scaffolder` | |
| gitAuthorEmail | string | - | |
| gitCommitMessage | string | Sets the commit message on the repository. The default value is `initial commit` | |
| dismissStaleReviews | boolean | New reviewable commits pushed to a matching branch will dismiss pull request review approvals. | |
| protectDefaultBranch | boolean | Protect the default branch after creating the repository. The default value is `true` | |
| protectEnforceAdmins | boolean | Enforce admins to adhere to default branch protection. The default value is `true` | |
| requiredCommitSigning | boolean | - | |
| requiredLinearHistory | boolean | - | |
| requireCodeOwnerReviews | boolean | Require an approved review in PR including files with a designated Code Owner | |
| requireLastPushApproval | boolean | Whether the most recent push to a PR must be approved by someone other than the person who pushed it. The default value is `false` | |
| bypassPullRequestAllowances | object | - | |
| requireBranchesToBeUpToDate | boolean | Require branches to be up to date before merging. The default value is `true` | |
| requiredStatusCheckContexts | array | The list of status checks to require in order to merge into this branch | |
| requiredApprovingReviewCount | number | Specify 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`. | |
| requiredConversationResolution | boolean | Requires all conversations on code to be resolved before a pull request can be merged into this branch |
Output Schema
| Property | Type | Description | Required |
|---|---|---|---|
| remoteUrl | string | A URL to the repository with the provider | |
| commitHash | string | The git commit hash of the initial commit | |
| repoContentsUrl | string | A URL to the root of the repository |
Usage Examples
Push to an existing GitHub repo on a feature branch
Pushes the scaffolded contents to an existing GitHub repository on a feature branch. Use this when the repository already exists and you want to add or update files generated during scaffolding.
steps:
- id: fetch-template
action: [fetch:template](/backstage/scaffolder-actions/fetch-template/)
input:
url: https://github.com/acme-org/software-templates/blob/main/service-template
targetPath: .
values:
componentId: ${{ parameters.componentId }}
owner: ${{ parameters.owner }}
description: ${{ parameters.description }}
- id: push-to-github
action: github:repo:push
input:
repoUrl: github.com?owner=acme-services&repo=${{ parameters.repoName }}
branch: feature/bootstrap-${{ parameters.componentId }}
commitMessage: "Bootstrap ${{ parameters.componentId }} via Backstage"
authorName: "Backstage Scaffolder"
authorEmail: "scaffolder@acme.io"
sourcePath: .
force: falseCreate a repo then push a subdirectory to main
Creates a new GitHub repository and pushes only a subdirectory of the workspace to the main branch. Use this when the template generates multiple packages and you want to publish a specific service folder.
steps:
- id: fetch-template
action: [fetch:template](/backstage/scaffolder-actions/fetch-template/)
input:
url: https://github.com/acme-org/software-templates/blob/main/monorepo-template
targetPath: .
values:
workspaceName: ${{ parameters.workspaceName }}
serviceName: ${{ parameters.componentId }}
owner: ${{ parameters.owner }}
- id: create-repo
action: [github:repo:create](/backstage/scaffolder-actions/github-repo-create/)
input:
repoUrl: github.com?owner=acme-services&repo=${{ parameters.repoName }}
- id: push-service
action: github:repo:push
input:
repoUrl: github.com?owner=acme-services&repo=${{ parameters.repoName }}
branch: main
commitMessage: "Add ${{ parameters.componentId }} service scaffold"
sourcePath: services/${{ parameters.componentId }}
force: true