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 template project whose files are added to 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 of the template project to clone. If not specified, the branch source_project_branch is used-
source_project_branchNoBranch of the template project to clone. It is used only to clone the templatemain
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 portal:

  1. Clones the template project (source_project_id) at the tag source_project_tag or, if the tag is not specified, at the branch source_project_branch. For more information, see Implementation details.
  2. Reads the values.yaml file stored at the root of the template 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. Clones the target project (target_project_id) at the branch merge_request_spec.target_branch.
  7. Creates the branch merge_request_spec.source_branch from merge_request_spec.target_branch in the clone and switches to it.
  8. Copies the rendered files to the target project, overwriting files with the same paths.
  9. Commits the changes and pushes the commit to the branch merge_request_spec.source_branch of the target project. The push is not forced: if this branch already exists in the target project and contains commits that are not in merge_request_spec.target_branch, the action fails.
  10. Creates an MR in the target project according to merge_request_spec 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.