Publish To Azure Repos

Action ID: publish:azure
NPM Package:

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

Description

Initializes a git repository of the content in the workspace, and publishes it to Azure.

Input Schema

PropertyTypeDescriptionRequired
tokenstringThe token to use for authorization to Azure
repoUrlstringRepository Location
signCommitbooleanSign commit with configured PGP private key
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
defaultBranchstring-
gitAuthorNamestring-
gitAuthorEmailstring-
gitCommitMessagestring-

Output Schema

PropertyTypeDescriptionRequired
remoteUrlstringA URL to the repository with the provider
commitHashstringThe git commit hash of the initial commit
repositoryIdstringThe Id of the created repository
repoContentsUrlstringA URL to the root of the repository

Usage Examples

Publish a new repository to Azure DevOps with default branch and description

Creates a new Azure DevOps repo from the generated workspace and sets the default branch. Use this when scaffolding a new service with a standard main branch. Starts with fetch:template and finishes by registering with catalog:register.

Copy
steps:
  - id: fetch-base
    name: Fetch template content
    action: fetch:template
    input:
      url: ./template
      values:
        serviceName: ${{ parameters.serviceName }}
        owner: ${{ parameters.owner }}

  - id: publish
    name: Publish to Azure DevOps
    action: publish:azure
    input:
      repoUrl: dev.azure.com?organization=${{ parameters.azureOrg }}&project=${{ parameters.project }}&repo=${{ parameters.repoName }}
      description: ${{ parameters.description }}
      defaultBranch: main
      gitCommitMessage: "chore: scaffold ${{ parameters.serviceName }}"

  - id: register
    name: Register in catalog
    action: catalog:register
    input:
      location:
        type: url
        target: ${{ steps.publish.output.repoContentsUrl }}/catalog-info.yaml

Publish only a subdirectory as the repository root

Publishes a specific subfolder from the workspace as the repository root. Use this when your template creates multiple components and you want to publish only one service folder.

Copy
steps:
  - id: fetch-mono
    name: Fetch monorepo template
    action: fetch:template
    input:
      url: ./template
      values:
        repoName: ${{ parameters.repoName }}
        project: ${{ parameters.project }}

  - id: publish-service
    name: Publish service subfolder
    action: publish:azure
    input:
      repoUrl: dev.azure.com?organization=${{ parameters.azureOrg }}&project=${{ parameters.project }}&repo=${{ parameters.repoName }}-api
      description: "API service for order processing"
      defaultBranch: main
      sourcePath: services/api
      gitAuthorName: "Backstage Scaffolder"
      gitAuthorEmail: "[email protected]"
      gitCommitMessage: "feat: initial API service scaffold"

  - id: register-service
    name: Register API in catalog
    action: catalog:register
    input:
      location:
        type: url
        target: ${{ steps['publish-service'].output.repoContentsUrl }}/catalog-info.yaml

Publish to an on‑prem Azure DevOps Server with an explicit token

Targets a self‑hosted Azure DevOps Server with a custom host and passes a Personal Access Token. Use this when your instance is not dev.azure.com or you need to override the integration token.

Copy
steps:
  - id: fetch-tpl
    name: Fetch template
    action: fetch:template
    input:
      url: ./template
      values:
        name: ${{ parameters.name }}
        owner: ${{ parameters.team }}

  - id: publish-ado-server
    name: Publish to on-prem Azure DevOps
    action: publish:azure
    input:
      repoUrl: ado.contoso.local?organization=${{ parameters.azureOrg }}&project=${{ parameters.project }}&repo=${{ parameters.repoName }}
      description: "Internal service deployed on-prem"
      defaultBranch: master
      token: ${{ parameters.azurePat }}
      gitCommitMessage: "init: scaffold ${{ parameters.name }}"

  - id: register-onprem
    name: Register component
    action: catalog:register
    input:
      location:
        type: url
        target: ${{ steps['publish-ado-server'].output.repoContentsUrl }}/catalog-info.yaml

Publish with a signed initial commit

Signs the initial commit using a configured PGP key on the runner. Use this when your organization requires signed commits for provenance.

Copy
steps:
  - id: fetch-src
    name: Fetch template
    action: fetch:template
    input:
      url: ./template
      values:
        component_id: ${{ parameters.componentId }}
        owner: ${{ parameters.owner }}

  - id: publish-signed
    name: Publish with signed commit
    action: publish:azure
    input:
      repoUrl: dev.azure.com?organization=${{ parameters.azureOrg }}&project=${{ parameters.project }}&repo=${{ parameters.componentId }}
      description: "Service with signed initial commit"
      defaultBranch: main
      gitAuthorName: "Platform Engineering"
      gitAuthorEmail: "[email protected]"
      gitCommitMessage: "chore: initial commit for ${{ parameters.componentId }} signed"
      signCommit: true

  - id: register-signed
    name: Register component
    action: catalog:register
    input:
      location:
        type: url
        target: ${{ steps['publish-signed'].output.repoContentsUrl }}/catalog-info.yaml

Publish to a develop branch from a docs-only subfolder

Starts the repository on a non‑default branch and publishes only the docs folder. Use this when bootstrapping documentation projects or when your main code is managed elsewhere.

Copy
steps:
  - id: fetch-docs
    name: Fetch docs template
    action: fetch:template
    input:
      url: ./template
      values:
        docsName: ${{ parameters.docsName }}
        project: ${{ parameters.project }}

  - id: publish-docs
    name: Publish docs to Azure DevOps
    action: publish:azure
    input:
      repoUrl: dev.azure.com?organization=${{ parameters.azureOrg }}&project=${{ parameters.project }}&repo=${{ parameters.docsRepo }}
      description: "Team documentation"
      defaultBranch: develop
      sourcePath: docs
      gitCommitMessage: "docs: bootstrap ${{ parameters.docsName }}"

  - id: register-docs
    name: Register docs component
    action: catalog:register
    input:
      location:
        type: url
        target: ${{ steps['publish-docs'].output.repoContentsUrl }}/catalog-info.yaml