GitHub or Bitbucket Synchronization with Cloud Code Import / Export

If you're using GitHub or Bitbucket for your repositories, Good News! It's possible to synchronize your Cloud Code with GitHub or Bitbucket via the Import/Export features available in the platform.

In this tutorial, we assume that you already know what GitHub or Bitbucket are and that you have either a GitHub or Bitbucket repository already created.

GitHub or Bitbucket? In this tutorial, we show you how to synchronize with GitHub to import/export your game's Cloud Code. The process for synchronizing with your Bitbucket repositories is essentially the same.

Exporting Cloud Code

The first thing we can do is export our Cloud Code to our local machine.

1. In your game, navigate to Configurator > Cloud Code and select the Export button at the bottom of the Scripts section.

The entire Cloud Code for the game will be downloaded as a .zip file to your local machine.

The contents of the .zip archive is structured on folders which resemble the categories as seen in the Portal's Cloud Code section. The contents of the .zip can look something like this:

You'll only see the directories in which you have created Cloud Code. For example, if you only have code for Events, User Messages, and Modules, you'll only be able to see those directories in your export.

In each directory where Cloud Code exists, you'll see a JavaScript (.js) file for every Cloud Code Event, Message, or Module:

This is the exported Cloud Code and it's structural layout.

2. Navigate back to the Configurator > Game Overview page and click to Create a Snapshot of the existing game.

3. Click to copy the Snapshot. A Copy Snapshot dialog appears:

4. Click Copy. When the Snapshot copy process has successfully completed, you'll get a message and you can click the View game hotlink to be taken straight to the new game you've created:

Merging Cloud Code into a GitHub Repository

In the following steps, some type of versioning control application will be useful in adding the Cloud Code to your choice of repository.

1. Extract the contents of the .zip archive into the local working directory that is the path of your GitHub repository.

2. Make changes to the overall collection of Cloud Code files you exported earlier:

3. Commit and push the changes that include the exported Cloud Code into the remote repository.

4. Navigate to your project on GitHub. You'll notice that the Cloud Code changes have been successfully pushed to your remote repository:

Importing Cloud Code

1. Go to the Configurator > Cloud Code section and select GitHub Import:

The GitHub Import page opens where you can use a hotlink to connect the GameSparks platform to your GitHub account:

2. Click to connect your account. A new browser tab is opened where you'll be required to log in again. When you've logged in, you're taken to your Account Management page:

3. Under Integrations, click the red Connect GitHub button. A GitHub Sign in page opens:

4. Enter your GitHub password and click Sign in. You are taken to an Authorize application page:

5. Click to Authorize application. This will allow the GameSparks platform to link to your GitHub account.

When the connection completes, you're taken back to your Account Management page where you'll see that the GitHub button has changed to green:

Now that the platform is connected to your GitHub account, you'll be able to select your data from your GitHub account repositories.

6. Navigate back to the tab for the GitHub Import page and click the Refresh button. When the page refreshes, all of the repositories for your GitHub account are listed:

7. Step 1: Select the repository from which you want import. The page shows the commits to the selected repository:

8. Step 2: Select the commit you want to import from. The commit is loaded:

9. Step 3: Select the root directory. The changes are loaded for ALL directories:

Select ROOT Directory! Although the directory structure is shown, you must select the root directory.

10. Step 4: Select the changes you want to import. You can scroll down to inspect the changes made to Cloud Code in all directories and decide which changes you want to import:

All Changes Selected! All Cloud Code changes are selected by default for import - unselect the check box for any changes that you don't want to import.

11. If you want to create a Snapshot of your game before you import the Cloud Code changes, select to Create Game Snapshot at the bottom of the page:

12. Click Import to import the selected Cloud Code changes.

Errors on Import

When you select the repository and commit you want to import from and the commit is loaded for import, errors might be generated. For details of these possible errors on import, check here.

Did this page help you? Please enter your feedback below.