Push To Azure Repos

Action ID: azure:repository:push
NPM Package:

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

Description

Push the content in the workspace to a remote Azure repository.

Input Schema

PropertyTypeDescriptionRequired
tokenstring-
branchstring-
remoteUrlstring-
sourcePathstring-
gitAuthorNamestring-
gitAuthorEmailstring-
gitCommitMessagestring-

Output Schema

No output schema defined for this action.

Usage Examples

Push a newly generated service to Azure DevOps main branch

Fetch a service template with fetch:template and push the result to the main branch of an Azure DevOps repository. Use this when creating a new service repository.

Copy
steps:
  - id: fetch-template
    action: fetch:template
    input:
      url: https://github.com/contoso/software-templates/catalog-service
      targetPath: .
      values:
        name: ${{ parameters.componentId }}
        owner: ${{ parameters.owner }}

  - id: push-to-azure
    action: azure:repository:push
    input:
      remoteUrl: https://dev.azure.com/contoso/Platform/_git/orders-service
      branch: main
      gitCommitMessage: chore: scaffold orders-service
      gitAuthorName: Backstage Scaffolder
      gitAuthorEmail: [email protected]
      token: ${{ secrets.azureToken }}

Push only a subdirectory to an Azure DevOps repo

Generate multiple components, then push only a specific subdirectory to the target repository using sourcePath. Use this when your workspace contains more than you want in the repo root.

Copy
steps:
  - id: fetch-template
    action: fetch:template
    input:
      url: https://github.com/contoso/software-templates/multi-service
      targetPath: .
      values:
        rootName: ${{ parameters.componentId }}
        includePayments: true

  - id: push-payments-service
    action: azure:repository:push
    input:
      remoteUrl: https://dev.azure.com/contoso/Platform/_git/payment-api
      branch: main
      sourcePath: services/payment-api
      gitCommitMessage: feat(payment-api): initial scaffold
      gitAuthorName: Scaffolder Bot
      gitAuthorEmail: [email protected]
      token: ${{ secrets.azureToken }}

Push to a feature branch for a work item

Create a feature branch named from a ticket identifier and push the generated files. Use this to open a PR from a feature branch.

Copy
steps:
  - id: fetch-template
    action: fetch:template
    input:
      url: https://github.com/contoso/software-templates/service-skeleton
      targetPath: .
      values:
        name: payments
        owner: ${{ parameters.owner }}

  - id: push-feature-branch
    action: azure:repository:push
    input:
      remoteUrl: https://dev.azure.com/contoso/Platform/_git/platform-services
      branch: feature/${{ parameters.ticketId }}-init-payments
      sourcePath: .
      gitCommitMessage: feat(payments): scaffold service for ${{ parameters.ticketId }}
      gitAuthorName: Backstage Scaffolder
      gitAuthorEmail: [email protected]
      token: ${{ secrets.azureToken }}

Push from a custom path with explicit author details

Generate an app in a nested folder and push only that folder. Provide explicit author identity for audit requirements.

Copy
steps:
  - id: fetch-template
    action: fetch:template
    input:
      url: https://github.com/contoso/software-templates/react-app
      targetPath: generated-app
      values:
        appName: ${{ parameters.componentId }}
        owner: ${{ parameters.owner }}

  - id: push-generated-app
    action: azure:repository:push
    input:
      remoteUrl: https://dev.azure.com/contoso/Web/_git/frontend-app
      branch: main
      sourcePath: generated-app
      gitCommitMessage: feat(frontend-app): bootstrap ${{ parameters.componentId }}
      gitAuthorName: Jane Developer
      gitAuthorEmail: [email protected]
      token: ${{ secrets.azureToken }}

Push to a monorepo using parameters for URL and token

Push a package folder into a monorepo branch using values supplied by template parameters. Use this when the repo URL and token are provided at runtime.

Copy
steps:
  - id: fetch-template
    action: fetch:template
    input:
      url: https://github.com/contoso/software-templates/node-package
      targetPath: packages/${{ parameters.componentId }}
      values:
        packageName: @contoso/${{ parameters.componentId }}
        owner: ${{ parameters.owner }}

  - id: push-monorepo
    action: azure:repository:push
    input:
      remoteUrl: ${{ parameters.repoUrl }}
      branch: chore/bootstrap-${{ parameters.componentId }}
      sourcePath: packages/${{ parameters.componentId }}
      gitCommitMessage: chore(${{ parameters.componentId }}): add initial package
      gitAuthorName: Scaffolder Bot
      gitAuthorEmail: [email protected]
      token: ${{ parameters.azurePat }}