# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
---
loader: taskgraph.loader.transform:loader

transforms:
    - gecko_taskgraph.transforms.merge_automation:transforms
    - gecko_taskgraph.transforms.task:transforms


tasks:
    merge-automation:
        name: merge-automation
        label: merge-automation
        treeherder:
            symbol: Rel(merge-automation)
            tier: 1
            kind: build
            platform: firefox-release/opt
        description: Merge repositories for release management.
        scopes:
            - "queue:route:notify.matrix-room.*"
        worker-type: lando
        worker:
            implementation: landoscript
            # lando-repo is the _destination_ repository; not the one
            # the task runs on. For this reason it is keyed on behavior
            # instead of project.
            lando-repo:
                by-project:
                    try:
                        by-behavior:
                            central-to-beta: staging-firefox-beta
                            early-to-late-beta: staging-firefox-beta
                            beta-to-release: staging-firefox-release
                            release-to-esr: staging-firefox-esr128
                            bump-central: staging-firefox-main
                            bump-esr128: staging-firefox-esr128
                    default:
                        by-behavior:
                            central-to-beta: firefox-beta
                            early-to-late-beta: firefox-beta
                            beta-to-release: firefox-release
                            release-to-esr: firefox-esr128
                            bump-central: firefox-main
                            bump-esr128: firefox-esr128
            dontbuild: false
            l10n-bump-info:
                by-behavior:
                    central-to-beta:
                        - name: Firefox l10n changesets
                          path: browser/locales/l10n-changesets.json
                          l10n-repo-url: https://github.com/mozilla-l10n/firefox-l10n
                          l10n-repo-target-branch: main
                          ignore-config:
                              ja:
                                  - macosx64
                                  - macosx64-devedition
                              ja-JP-mac:
                                  - linux
                                  - linux-devedition
                                  - linux64
                                  - linux64-aarch64
                                  - linux64-devedition
                                  - linux64-aarch64-devedition
                                  - win32
                                  - win32-devedition
                                  - win64
                                  - win64-devedition
                                  - win64-aarch64
                                  - win64-aarch64-devedition
                          platform-configs: [{
                              "platforms": [
                                  "linux",
                                  "linux-devedition",
                                  "linux64",
                                  "linux64-aarch64",
                                  "linux64-devedition",
                                  "linux64-aarch64-devedition",
                                  "macosx64",
                                  "macosx64-devedition",
                                  "win32",
                                  "win32-devedition",
                                  "win64",
                                  "win64-devedition",
                                  "win64-aarch64",
                                  "win64-aarch64-devedition",
                              ],
                              "path": "browser/locales/shipped-locales",
                          }]
                        - name: mobile l10n changesets
                          path: mobile/locales/l10n-changesets.json
                          l10n-repo-url: https://github.com/mozilla-l10n/firefox-l10n
                          l10n-repo-target-branch: main
                          platform-configs: [
                              {
                                  "platforms":
                                      [
                                          "android",
                                          "android-arm",
                                          "android-multilocale",
                                      ],
                                  "path": "mobile/android/locales/all-locales",
                              },
                          ]
                    default: null
        run-on-projects: []
        expiration-policy: long
        routes:
            by-level:
                '3':
                    # #releaseduty
                    - "notify.matrix-room.!tBWwNyfeKqGvkNpdDL:mozilla.org.on-pending"
                    - "notify.matrix-room.!tBWwNyfeKqGvkNpdDL:mozilla.org.on-resolved"
                default:
                    # #releaseduty-dev
                    - "notify.matrix-room.!wGgsWXnVncJLSBYmuf:mozilla.org.on-pending"
                    - "notify.matrix-room.!wGgsWXnVncJLSBYmuf:mozilla.org.on-resolved"
        extra:
            notify:
                matrixBody:
                    $let:
                        dry_run:
                            $if: "'dry_run' in task.payload && task.payload.dry_run"
                            then: " (dry run)"
                            else: ""
                    in: "merge-automation task ${task.metadata.name}${dry_run} is now ${status.state}: https://firefox-ci-tc.services.mozilla.com/tasks/${taskId}"
