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: 123Request specification
| Name | Required | Description | Default value |
|---|---|---|---|
| source_project_id | Yes | Identifier of the template project whose files are added to the Merge Request | - |
| target_project_id | Yes | Identifier of the target project in which the Merge Request will be created | - |
| merge_request_spec | Yes | Specification matching the GitLab Merge Requests API | - |
| source_project_tag | No | Tag of the template project to clone. If not specified, the branch source_project_branch is used | - |
| source_project_branch | No | Branch of the template project to clone. It is used only to clone the template | main |
| additionalIgnoreFiles | No | List of files containing paths to exclude from the MR. Populated similarly to .templateignore | - |
| values | No | Variables used during templating, in key: value format | - |
How it works
The portal:
- Clones the template project (
source_project_id) at the tagsource_project_tagor, if the tag is not specified, at the branchsource_project_branch. For more information, see Implementation details. - Reads the
values.yamlfile stored at the root of the template repository and determines the default templating variables. - Reads the variables passed when the action is launched and merges them with the variables from
values.yaml. Variables passed at launch take priority. - Reads the
.templateignorefile and determines the directories and files excluded from templating. - Renders the files from the templates, taking into account
values.yamland the variables passed to the action. - Clones the target project (
target_project_id) at the branchmerge_request_spec.target_branch. - Creates the branch
merge_request_spec.source_branchfrommerge_request_spec.target_branchin the clone and switches to it. - Copies the rendered files to the target project, overwriting files with the same paths.
- Commits the changes and pushes the commit to the branch
merge_request_spec.source_branchof the target project. The push is not forced: if this branch already exists in the target project and contains commits that are not inmerge_request_spec.target_branch, the action fails. - Creates an MR in the target project according to
merge_request_specby sending a POST request to the GitLab API.
Note
The action performs a POST request to the URL: /api/v4/projects/:id/merge_requests.