Publish GitLab Merge Request

Action ID: publish:gitlab:merge-request
NPM Package:

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

Description

Publishes a merge request to GitLab with specified title, branch, and additional options.

Input Schema

PropertyTypeDescriptionRequired
titlestring-
tokenstring-
labelsstring-
repoUrlstring-
assigneestring-
projectidstring-
reviewersarray-
branchNamestring-
sourcePathstring-
targetPathstring-
descriptionstring-
commitActionstring-
targetBranchNamestring-
removeSourceBranchboolean-
assignReviewersFromApprovalRulesboolean-

Output Schema

PropertyTypeDescriptionRequired
projectidstring-
projectPathstring-
mergeRequestUrlstring-
targetBranchNamestring-

Usage Examples

Create a feature merge request into main with reviewers and labels

Creates a new branch and merge request to add a service skeleton into a monorepo after generating files with fetch:template. Use this when proposing a new service under a services directory.

Copy
steps:
  - id: fetch-template
    action: fetch:template
    input:
      url: ./skeleton
      values:
        componentId: ${{ parameters.componentId }}
        owner: ${{ parameters.owner }}

  - id: open-feature-mr
    action: publish:gitlab:merge-request
    input:
      repoUrl: gitlab.com?project=acme%2Fplatform
      title: Add ${{ parameters.componentId }} service
      description: Scaffolding for ${{ parameters.componentId }} service
      branchName: feat/${{ parameters.componentId }}-service
      targetBranchName: main
      sourcePath: .
      targetPath: services/${{ parameters.componentId }}
      labels: service,scaffolder
      reviewers:
        - alice
        - bob
      assignee: alice
      token: ${{ secrets.gitlabToken }}

Open a compliance update MR using project ID and approval rules

Publishes a merge request against the develop branch using a project ID and auto assigns reviewers from approval rules. Use this for automated policy updates after fetch:template.

Copy
steps:
  - id: fetch-policies
    action: fetch:template
    input:
      url: ./generated/policies
      targetPath: generated/policies
      values:
        policyVersion: ${{ parameters.policyVersion }}

  - id: open-compliance-mr
    action: publish:gitlab:merge-request
    input:
      repoUrl: gitlab.com?project=acme%2Fcompliance-policies
      projectid: "4521"
      title: Update policies to version ${{ parameters.policyVersion }}
      description: Automated policy refresh for version ${{ parameters.policyVersion }}
      branchName: chore/policies-${{ parameters.policyVersion }}
      targetBranchName: develop
      sourcePath: generated/policies
      targetPath: policies
      commitAction: create
      removeSourceBranch: true
      assignReviewersFromApprovalRules: true
      labels: compliance,automation
      token: ${{ secrets.gitlabToken }}

Update documentation in root with an existing branch

Creates or updates a docs branch and opens a merge request to update repository level docs. Use this when publishing generated docs from a prior fetch:template step.

Copy
steps:
  - id: generate-docs
    action: fetch:template
    input:
      url: ./docs-template
      targetPath: output/docs
      values:
        componentId: ${{ parameters.componentId }}
        description: ${{ parameters.description }}

  - id: open-docs-mr
    action: publish:gitlab:merge-request
    input:
      repoUrl: gitlab.com?project=acme%2Fcheckout
      title: Docs for ${{ parameters.componentId }}
      description: Generated documentation for ${{ parameters.componentId }}
      branchName: docs/${{ parameters.componentId }}-readme
      sourcePath: output/docs
      targetPath: .
      commitAction: update
      reviewers:
        - techwriter1
      labels: docs
      removeSourceBranch: false

Propose config refactor into a stable branch with explicit assignee

Opens a merge request targeting a stable branch and assigns an owner. Use this when refactoring config files produced by fetch:template.

Copy
steps:
  - id: render-config
    action: fetch:template
    input:
      url: ./config-template
      targetPath: workspace/config
      values:
        systemId: ${{ parameters.systemId }}

  - id: open-config-mr
    action: publish:gitlab:merge-request
    input:
      repoUrl: gitlab.com?project=acme%2Fops-inventory
      title: Refactor config for ${{ parameters.systemId }}
      description: Move and normalize config for ${{ parameters.systemId }}
      branchName: refactor/${{ parameters.systemId }}-config
      targetBranchName: stable
      sourcePath: workspace/config
      targetPath: config/${{ parameters.systemId }}
      assignee: ops-bot
      reviewers:
        - ops-lead
        - sre-oncall
      labels: config,refactor
      token: ${{ secrets.gitlabPersonalAccessToken }}

Add a new Helm chart under a monorepo path with source branch cleanup

Creates a merge request to add a Helm chart under a specific directory and cleans up the source branch after merge. Use this for platform changes generated via fetch:template.

Copy
steps:
  - id: scaffold-chart
    action: fetch:template
    input:
      url: ./helm-chart
      targetPath: charts/${{ parameters.chartName }}
      values:
        chartName: ${{ parameters.chartName }}
        owner: ${{ parameters.owner }}

  - id: open-chart-mr
    action: publish:gitlab:merge-request
    input:
      repoUrl: gitlab.com?project=acme%2Finfrastructure
      title: Add Helm chart ${{ parameters.chartName }}
      description: Introduce chart ${{ parameters.chartName }} to the helm directory
      branchName: feat/helm-${{ parameters.chartName }}
      targetBranchName: main
      sourcePath: charts/${{ parameters.chartName }}
      targetPath: helm/${{ parameters.chartName }}
      removeSourceBranch: true
      reviewers:
        - platform-owner
        - devops
      labels: helm,platform