> ## Documentation Index
> Fetch the complete documentation index at: https://docs.directgvr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure the launcher to download your repositories

> Set up your launcher's workflow to check, sync and repair one or more repositories.

This page shows how to set up your launcher's workflow to sync your repositories. You need at least one repository deployed and assigned to an environment. See [Deploy a release](https://docs.directgvr.com/release-automation/deploy-a-release.md) and [Create environments and promote releases](https://docs.directgvr.com/release-automation/environments-and-promotion.md).

The examples use two repositories, `hi-res-paintings` and `nasaimages`, promoted to an environment named `stage`.

> [!NOTE]
>
> These examples use `workflow.json`. The current launcher template uses `public/workflow.yaml`; the tasks are the same in either format. See [Use YAML configuration and workflow files](https://docs.directgvr.com/launcher-design/yaml-files.md).

## Organize your macros

Split macros into general ones and a set per repository. The `load` task always runs first, so load the macros there. See [Tasks](https://docs.directgvr.com/reference/client-workflow-engine/tasks.md).

```json workflow.json theme={null}
"generalMacros": {
  "type": "macro",
  "keyValuePairs": {
    "environment": "stage",
    "aliasUrl": "https://cdn.example.com/game/",
    "installRoot": "{moduleDirectory}ClientFiles{pathSlash}",
    "repositoryLauncher": "game-launcher",
    "repositoryLauncherTitle": "Game Launcher",
    "selfUpdateDirectory": "{moduleDirectory}",
    "executableName-win": "path/to/client.exe"
  }
},
"repositoryOneMacros": {
  "type": "macro",
  "keyValuePairs": {
    "repository": "hi-res-paintings",
    "repositoryTitle": "Hi-Res Paintings",
    "installDirectory": "{installRoot}Paintings{pathSlash}",
    "repositoryName": "{repository}.{environment}",
    "repositoryMetafile": "{repositoryName}.metafile",
    "repositoryAliasUrl": "{aliasUrl}{repository}/alias.json",
    "repositoryCatalogUrl": "{aliasUrl}{repository}/catalog/"
  }
},
"repositoryTwoMacros": {
  "type": "macro",
  "keyValuePairs": {
    "repositoryTwo": "nasaimages",
    "repositoryTitleTwo": "NASA Images",
    "installDirectoryTwo": "{installRoot}NASA{pathSlash}",
    "repositoryNameTwo": "{repositoryTwo}.{environment}",
    "repositoryMetafileTwo": "{repositoryTwo}.metafile",
    "repositoryAliasUrlTwo": "{aliasUrl}{repositoryTwo}/alias.json",
    "repositoryCatalogUrlTwo": "{aliasUrl}{repositoryTwo}/catalog/"
  }
},
"load": {
  "type": "queue",
  "concurrentTasks": 1,
  "actions": [ "generalMacros", "repositoryOneMacros", "repositoryTwoMacros" ]
},
```

## Set the general macros

* `aliasUrl`: the folder on your CDN where you deploy your repositories.
* `installRoot`: where repositories are installed on the player's machine.
* `environment`: the environment you [promoted the releases](https://docs.directgvr.com/release-automation/environments-and-promotion.md) to.

> [!TIP]
>
> Use an HTTPS URL for `aliasUrl`. The alias file is overwritten on the CDN every time you promote a release, and HTTPS stops ISPs from caching an old copy.

## Set the repository macros

Each repository gets its own set. Copy the set for each additional repository.

* `repository`: the repository name you used when deploying.
* `repositoryTitle`: the name shown in the launcher while the repository syncs.
* `installDirectory`: where this repository's files go on the player's machine, under `installRoot`.
* `repositoryName`: the repository and environment names combined.
* `repositoryMetafile`: the metafile name saved on the player's machine. The launcher uses it like a version file to check for updates.
* `repositoryAliasUrl`: the URL of this repository's `alias.json`.

The rest of this page describes the tasks each repository needs. You only change them if you have three or more repositories.

## Add every repository to the update task

The reserved `update` task runs at every update interval. Make it a progress task so the launcher shows one progress bar for all repositories, and list each repository's check:

```json theme={null}
"update": {
  "type": "progress",
  "status": ["UI_CheckingForUpdate", "UI_Done"],
  "taskChainParameter": ["equalTo", "notEqualTo", "start", "missing", "read", "writable", "lessThan", "update"],
  "actions": ["updateCheck", "updateCheckTwo"],
  "verbose": false
},
```

`update` and `install` are listed in `taskChainParameter` because the check tasks route to other tasks through them. See [Tasks](https://docs.directgvr.com/reference/client-workflow-engine/tasks.md) and [Progress](https://docs.directgvr.com/reference/client-workflow-engine/progress.md).

## Check each repository

A `repositoryCheck` task compares the ID in the local metafile, if there is one, with the required ID in the alias file:

```json theme={null}
"updateCheck": {
  "type": "repositoryCheck",
  "repository": "{repositoryName}",
  "catalog": "{repositoryCatalogUrl}",
  "alias": "{repositoryAliasUrl}",
  "title": "{repositoryTitle}",
  "metafile": "{installDirectory}{repositoryMetafile}.json",
  "update": "updateElevatedCheck",
  "install": "updateElevatedCheck",
  "progressWeight": 0
},
"updateCheckTwo": {
  "type": "repositoryCheck",
  "repository": "{repositoryNameTwo}",
  "catalog": "{repositoryCatalogUrlTwo}",
  "alias": "{repositoryAliasUrlTwo}",
  "title": "{repositoryTitleTwo}",
  "metafile": "{installDirectoryTwo}{repositoryMetafileTwo}.json",
  "update": "updateElevatedCheck",
  "install": "updateElevatedCheck",
  "progressWeight": 0
},
```

If a repository needs an update, the workflow goes to `updateElevatedCheck`, which checks whether the install folder needs administrator rights (for example `C:\Program Files\`). If it does, the launcher shows a User Account Control prompt.

```json theme={null}
"updateElevatedCheck": {
  "type": "directoryIsWritable",
  "path": "{installRoot}",
  "recurse": true,
  "writable": "updateActions",
  "notWritable": "updateActionsElevated",
  "progressWeight": 0
},
```

## Sync each repository

A `repositorySync` task downloads the files for a first install or an update:

```json theme={null}
"updateSync": {
  "type": "repositorySync",
  "status": "UI_Updating",
  "repository": "{repositoryName}",
  "catalog": "{repositoryCatalogUrl}",
  "alias": "{repositoryAliasUrl}",
  "title": "{repositoryTitle}",
  "metafile": "{installDirectory}{repositoryMetafile}.json",
  "local": { "type": "file", "path": "{installDirectory}" },
  "pending": { "type": "filePiece", "path": "{installDirectory}pending" }
},
```

Add a matching `updateSyncTwo` with the `Two` macros for the second repository.

## Repair each repository

A repair task is a `repositorySync` task with `"repair": true`. The launcher scans the local files and syncs only those that don't match.

```json theme={null}
"repairSync": {
  "type": "repositorySync",
  "repository": "{repositoryName}",
  "catalog": "{repositoryCatalogUrl}",
  "alias": "{repositoryAliasUrl}",
  "title": "{repositoryTitle}",
  "metafile": "{installDirectory}{repositoryMetafile}.json",
  "local": { "type": "file", "path": "{installDirectory}" },
  "repair": true
},
```

The repair tasks run from the `repair` progress task, which checks for elevation first. In the launcher template, it runs when the player clicks **Repair**.

```json theme={null}
"repair": {
  "type": "progress",
  "status": ["UI_Repairing", "UI_Done"],
  "taskChainParameter": ["equalTo", "notEqualTo", "start", "missing", "read", "writable", "lessThan", "update"],
  "actions": ["repairElevatedCheck"],
  "verbose": false
},
```

## Test the workflow

Load the skin to test it. See [Test a launcher skin with the CEF debugging console](https://docs.directgvr.com/troubleshooting/cef-debugging-console.md). You can also [compile the launcher](https://docs.directgvr.com/release-automation/builder-script.md) and run it.

## Related

* [Create environments and promote releases](https://docs.directgvr.com/release-automation/environments-and-promotion.md)
* [Tasks](https://docs.directgvr.com/reference/client-workflow-engine/tasks.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.