GitLab Repo Push

Action ID: gitlab:repo:push
NPM Package:

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

Description

Pushes changes to a specified GitLab repository branch with a defined commit message and action.

Input Schema

PropertyTypeDescriptionRequired
tokenstringThe token to use for authorization to GitLab
repoUrlstring-
branchNamestringThe branch name for the commit
sourcePathstringSubdirectory of working directory to copy changes from
targetPathstringSubdirectory of repository to apply changes to
commitActionstring-
commitMessagestring-

Output Schema

PropertyTypeDescriptionRequired
projectidstringGitlab Project id/Name(slug)
commitHashstringThe git commit hash of the commit
projectPathstringGitlab Project path

Usage Examples

Push generated service files to a new feature branch

Pushes newly generated service files to a GitLab repository on a feature branch. Use this after rendering files with fetch:template.

Copy
steps:
  - id: fetchServiceTemplate
    action: fetch:template
    input:
      url: ./templates/service
      targetPath: ./generated/service
      values:
        name: ${{ parameters.serviceName }}
        owner: platform-team

  - id: pushServiceScaffold
    action: gitlab:repo:push
    input:
      repoUrl: gitlab.com?owner=platform&repo=${{ parameters.serviceSlug }}
      branchName: feature/bootstrap-ci
      commitMessage: "Add CI and catalog files for ${{ parameters.serviceName }}"
      sourcePath: generated/service
      targetPath: .
      commitAction: create

Update documentation in the docs folder

Updates existing files under the docs directory using a dedicated branch. Use this to publish generated docs artifacts, with credentials passed via a secret.

Copy
steps:
  - id: buildDocs
    action: fetch:template
    input:
      url: ./templates/docs
      targetPath: ./docs-build
      values:
        service: ${{ parameters.serviceName }}
        repo: ${{ parameters.repoName }}

  - id: pushDocsUpdate
    action: gitlab:repo:push
    input:
      repoUrl: gitlab.com?owner=${{ parameters.repoOwner }}&repo=${{ parameters.repoName }}
      branchName: docs/update-${{ parameters.serviceSlug }}
      commitMessage: "Update service documentation"
      sourcePath: docs-build
      targetPath: docs
      commitAction: update
      token: ${{ secrets.gitlabToken }}

Delete a legacy directory from the repository

Removes an obsolete directory from the repo on a chore branch. Use this when cleaning up deprecated manifests or assets.

Copy
steps:
  - id: removeLegacyManifests
    action: gitlab:repo:push
    input:
      repoUrl: gitlab.com?owner=platform&repo=payments
      branchName: chore/remove-legacy-k8s
      commitMessage: "Remove legacy Kubernetes manifests"
      targetPath: k8s/overlays/dev-old
      commitAction: delete
      token: ${{ secrets.gitlabToken }}

Update a nested package folder in a monorepo

Updates files under a nested package path in a monorepo. Use this after generating code into a workspace subfolder with fetch:template.

Copy
steps:
  - id: generateApiClient
    action: fetch:template
    input:
      url: ./templates/api-client
      targetPath: ./gen/api-client
      values:
        apiSpecUrl: ${{ parameters.openapiUrl }}

  - id: pushApiClientUpdate
    action: gitlab:repo:push
    input:
      repoUrl: gitlab.com?owner=${{ parameters.groupPath }}&repo=${{ parameters.repoName }}
      branchName: feature/update-api-client
      commitMessage: "Regenerate API client from ${{ parameters.openapiUrl }}"
      sourcePath: gen/api-client
      targetPath: packages/api-client
      commitAction: update
      token: ${{ secrets.gitlabToken }}

Create a release branch with versioned release notes

Adds new release notes under a versioned path on a release branch. Use this to publish release artifacts created via fetch:template.

Copy
steps:
  - id: generateReleaseNotes
    action: fetch:template
    input:
      url: ./templates/release-notes
      targetPath: ./release-notes
      values:
        version: ${{ parameters.version }}
        changes: ${{ parameters.changelog }}

  - id: pushReleaseNotes
    action: gitlab:repo:push
    input:
      repoUrl: gitlab.com?owner=${{ parameters.repoOwner }}&repo=${{ parameters.repoName }}
      branchName: release/${{ parameters.version }}
      commitMessage: "Add release notes for ${{ parameters.version }}"
      sourcePath: release-notes
      targetPath: docs/releases/${{ parameters.version }}
      commitAction: create