Skip to main content

Continuous Integration (CI)

Continuous integration​

In order to integrate the Cloud Cooking Configuration steps into a programattic workflow, such as a CI/CD pipeline where you generate new tooling and builds to upload to the Azure Storage instance for your game, you can follow these steps.

Step 1​

Obtain a Service Token with the update scope.

curl -L -g -X POST 'https://g-{your-game-id}.modapi.io/v1/oauth/token' \
-H 'Accept: application/json' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'client_id=<client_id_goes_here>' \
-d 'client_secret=<client_secret_goes_here>' \
-d 'grant_type=client_credentials' \
-d 'scope=update'

Step 2​

Generate an Azure SAS token to upload your build tool to the dedicated Azure Storage for your games cloud cooking infrastructure. Use the token generated from the proceeding step in the Authorization header.

curl -L -g -X POST 'https://g-{your-game-id}.modapi.io/v1/games/:game-id/cloud-cooking/sas-token' \
-H 'Accept: application/json' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Authorization: Bearer <token>' \
-d 'valid_for_days=7' # must be between 1 and 365

Step 3​

Upload your build to Azure Storage using the token generated above, following the instructions and guidelines in Cloud Cooking Setup Guides to ensure your build provides everything required to cook a mod file.

Step 4​

Call the Cloud Cooking Finalization Endpoint. This endpoint should be called each time you upload new builds in order for the cook agents to reflect your changes. This is an asynchronous operation which can take 2 hours+ (depending on engine and provisioning scripts) to create a new virtual machine image. It will transition your games cloud_cooking_status to finalizing.

curl -L -g -X POST 'https://g-{your-game-id}.modapi.io/v1/games/:game-id/cloud-cooking/finalization' \
-H 'Authorization: Bearer <token>'

Step 5​

Configure a webhook to be notified of the success or failure of the finalize operation. This can be found under the Moderation > Automation menu item in your game admin settings. Add a new rule to the ruleset. The action should be Cloud Cooking Webhook, it should fire a webhook, and the when condition should match the payload field as illustrated:

Configuring a rules engine automation rule to fire a webhook on Cloud Cooking finalization events.
Configuring a rules engine automation rule to fire a webhook on Cloud Cooking finalization events.

The webhook will receive a response in the following shape:

{
// Other fields will also be present on the payload.
// Refer to our "Rules Engine" documentation for details
"event_body": {
"game_id": 7049,
"workflow": "finalize",
"status": 200 // 200 for success, 422 for failure
}
}

As implied, a success of 200 indicates the finalization operation succeeded. Whereas a 422 indicates failure.

A visual representation of this flow is as follows.