diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 833113758812b28c973090ed8559a8a1c5805d8a..048c6e544d2efe46fc89b77e37a28fae6a69ef4e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -185,7 +185,7 @@ build-yocto:kirkstone:
       when: manual
       allow_failure: true
   variables:
-    MERGE: --merge
+    MERGE: --merge --project=${CI_PROJECT_PATH} --branch=${CI_COMMIT_REF_NAME}
 
 merge-ci-test:
   extends:
diff --git a/scripts/deploy_gitlab_ci.py b/scripts/deploy_gitlab_ci.py
index eac312ee0c0db1947fc5ceec3d7cc86a0f9fa92d..fb5a48dd27c0350830e2b8abe67f42e499fe7501 100755
--- a/scripts/deploy_gitlab_ci.py
+++ b/scripts/deploy_gitlab_ci.py
@@ -11,10 +11,7 @@ from accept_merge_request import accept_merge_request
 from create_merge_request import create_merge_request
 from get_integration_sources import get_integration_sources
 from get_merge_requests import get_merge_requests
-from update_submodule import (
-    update_submodule_and_include_ref,
-    get_submodule_project_path_and_revision,
-)
+from update_submodule import update_submodule_and_include_ref
 from integrate_into_manifest import update_manifest, update_srcrev
 
 from ruamel.yaml import YAML
@@ -143,6 +140,20 @@ def main():
         required=False,
         default=False,
     )
+    parser.add_argument(
+        "--project",
+        help="""gitlab-ci project path or id""",
+        dest="project",
+        default=os.environ.get("CI_PROJECT_PATH"),
+        required=False,
+    )
+    parser.add_argument(
+        "--branch",
+        help="""gitlab-ci branch that we're merging into""",
+        dest="branch",
+        default="master",
+        required=False,
+    )
     parser.add_argument(
         "--manifest-file",
         help="""manifest file name (default: 'default.xml')""",
@@ -234,17 +245,10 @@ def main():
     # =======================================================
     if args.merge:
         # Get source merge request (the one in the gitlab-ci repo)
-        branch = manifest_integrations[0]["master_branch"]
-        if branch is None:
-            branch = manifest_integrations[0]["project"].default_branch
-        submodule_project_path, _ = get_submodule_project_path_and_revision(
-            manifest_integrations[0]["project"], args.submodule, branch
-        )
-        submodule_project = common.get_project(gitlab, submodule_project_path)
         mrs = get_merge_requests(
-            submodule_project,
-            # TODO should this be submodule_project's default branch?
-            target_branch="master",
+            project=args.project,
+            target_branch=args.branch,
+            state="merged",
             commit=args.revision,
         )
         if not mrs: