Initializes a git repository of the content in the workspace, and publishes it to Gerrit.
Input Schema
| Property | Type | Description | Required |
|---|---|---|---|
| repoUrl | string | Repository Location | |
| signCommit | boolean | Sign commit with configured PGP private key | |
| sourcePath | string | - | |
| description | string | Repository Description | |
| defaultBranch | string | - | |
| gitAuthorName | string | - | |
| gitAuthorEmail | string | - | |
| gitCommitMessage | string | - |
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
Publish a new service to Gerrit with default branch main
Publishes a freshly generated service to Gerrit using the main branch. Use this when creating a new project with a straightforward initial commit.
steps:
- id: fetch-template
action: fetch:template
input:
url: https://github.com/acme/templates/backend-service
values:
componentId: ${{ parameters.componentId }}
owner: ${{ parameters.owner }}
description: ${{ parameters.description }}
- id: publish-to-gerrit
action: publish:gerrit
input:
repoUrl: "gerrit.acme.corp?project=platform/${{ parameters.componentId }}"
description: "Payments API service"
defaultBranch: main
gitAuthorName: "Scaffolder Bot"
gitAuthorEmail: "[email protected]"
gitCommitMessage: "chore: scaffold ${{ parameters.componentId }} from template"Publish a subdirectory to Gerrit from a multi-service template
Publishes only a specific subdirectory from the workspace to Gerrit. Use this when your template generates multiple services and you want to create one Gerrit project per service.
steps:
- id: fetch-template
action: fetch:template
input:
url: https://github.com/acme/templates/multi-service-repo
values:
componentId: ${{ parameters.componentId }}
language: ${{ parameters.language }}
- id: publish-service-subdir
action: publish:gerrit
input:
repoUrl: "gerrit.acme.corp?project=services/${{ parameters.componentId }}"
description: "Service ${{ parameters.componentId }} generated from multi-service template"
sourcePath: "services/${{ parameters.componentId }}"
defaultBranch: main
gitAuthorName: "Scaffolder Bot"
gitAuthorEmail: "[email protected]"
gitCommitMessage: "feat: initialize ${{
parameters.componentId
}} service"Publish with signed initial commit and register in the catalog
Publishes with GPG-signed commit metadata and then registers the new component in Backstage. Use this when your organization enforces signed commits.
steps:
- id: fetch-template
action: fetch:template
input:
url: https://github.com/acme/templates/node-service
values:
componentId: ${{ parameters.componentId }}
owner: ${{ parameters.owner }}
description: ${{ parameters.description }}
- id: publish-gerrit-signed
action: publish:gerrit
input:
repoUrl: "gerrit.acme.corp?project=platform/${{ parameters.componentId }}"
description: "Node service ${{ parameters.componentId }}"
defaultBranch: main
gitAuthorName: ${{ parameters.gitAuthorName }}
gitAuthorEmail: ${{ parameters.gitAuthorEmail }}
gitCommitMessage: "chore: initial commit for ${{ parameters.componentId }}"
signCommit: true
- id: register
action: catalog:register
input:
catalogInfoUrl: "${{ steps['publish-gerrit-signed'].outputs.repoContentsUrl }}/catalog-info.yaml"This example uses fetch:template and catalog:register alongside publish:gerrit.
Publish to a non-main default branch develop
Publishes the repository with develop as the default branch. Use this when your workflow promotes changes from develop to main after review.
steps:
- id: fetch-skeleton
action: fetch:plain
input:
url: https://github.com/acme/starters/go-service.tar.gz
- id: publish-to-gerrit-develop
action: publish:gerrit
input:
repoUrl: "gerrit.acme.corp?project=teams/payments/${{ parameters.componentId }}"
description: "Go service ${{ parameters.componentId }} with develop as default branch"
defaultBranch: develop
gitAuthorName: "Backstage CI"
gitAuthorEmail: "[email protected]"
gitCommitMessage: "init(${{
parameters.componentId
}}): scaffold on develop"This example uses fetch:plain to bring in a starter, then publishes to Gerrit.
Publish using dynamic Gerrit host and project from parameters
Builds the repoUrl dynamically from user inputs, useful for multi-tenant Gerrit setups or when selecting a target host at runtime.
steps:
- id: fetch-template
action: fetch:template
input:
url: https://github.com/acme/templates/python-lib
values:
componentId: ${{ parameters.componentId }}
owner: ${{ parameters.owner }}
- id: publish-to-parametrized-gerrit
action: publish:gerrit
input:
repoUrl: "${{ parameters.gerritHost }}?project=${{ parameters.projectPath }}"
description: "Python library ${{ parameters.componentId }} published to ${{ parameters.projectPath }}"
defaultBranch: main
gitAuthorName: ${{ parameters.gitAuthorName }}
gitAuthorEmail: ${{ parameters.gitAuthorEmail }}
gitCommitMessage: "build: scaffold ${{ parameters.componentId }}"
sourcePath: "."In this example, parameters.gerritHost could be like gerrit.acme.corp and parameters.projectPath like libs/${{ parameters.componentId }}.