Running this action requires credentials:

  • password — the password (token) for the user on whose behalf the action will run.
  • username — the username of the user on whose behalf the action will run.

CreateGitlabMergeRequest — creates a new Merge Request (MR) in the target repository. Files stored in the source repository are added to the Merge Request. Files may contain variables whose values will be substituted at the time the MR is created.

Request example

source_project_id: '0'
source_project_branch: example
source_project_tag: v1.0.0
target_project_id: '0'
merge_request_spec:
  source_branch: example
  target_branch: '1'
  title: example
additionalIgnoreFiles:
  - .ignore
  - .example
values:
  key1: value1
  nested:
    enabled: true
    subkey: 123

Request specification

NameRequiredDescriptionDefault value
source_project_idYesIdentifier of the project that serves as the source for the Merge Request-
target_project_idYesIdentifier of the target project in which the Merge Request will be created-
merge_request_specYesSpecification matching the GitLab Merge Requests API-
source_project_tagNoTag in the source project from which the Merge Request will be created. If not specified, the source project’s branch is used-
source_project_branchNoBranch in the source project from which the Merge Request will be createdmain
additionalIgnoreFilesNoList of files containing paths to exclude from the MR. Populated similarly to .templateignore-
valuesNoVariables used during templating, in key: value format-

How it works

The platform:

  1. Clones the template repository used to generate the MR, based on its identifier (source_project_id). For more information, see Implementation details.
  2. Reads the values.yaml file stored at the root of the repository and determines the default templating variables.
  3. Reads the variables passed when the action is launched and merges them with the variables from values.yaml. Variables passed at launch take priority.
  4. Reads the .templateignore file and determines the directories and files excluded from templating.
  5. Renders the files from the templates, taking into account values.yaml and the variables passed to the action.
  6. Changes the repository remote to the target repository identified by target_project_id, then runs git push to the branch in the source project (source_project_branch) or to the main branch.
  7. Creates an MR according to the specified settings by sending a POST request to the GitLab API.

Note

The action performs a POST request to the URL: /api/v4/projects/:id/merge_requests.