Designing a Distributed System for an Online Multiplayer Game — CI/CD (Part 8)

Continuous Integration (CI)

Branch rules

The main branch is protected and nobody can push to it directly, thus a pull request must be created for each merge and a test job is run for it. Only the pull requests that have passed the test job are mergeable to the main branch.

Staging environment

When a pull request to the main branch of the game manager repository has been closed (merged), a Github action starts a job to build the docker image and publishes the artifact with the commit-hash tag to the GitHub container registry.

Production environment

When a new version of the game manager is released (tagged with semantic version), a GitHub action starts a job to build the docker image and publishes the artifact with the tag to the GitHub container registry.

Continuous Deployment

Staging Environment

After publishing the image to the ghcr, an event with the artifact’s tag (commit sha hash) is dispatched from the game manager's repository to update the image version in the staging environment. On the other side, the k8s repository GitHub action receives the event and starts a job to install kubectl and update the image of the game manager k8s deployment resource.

Production Environment

Same as the staging environment, after releasing the game manager package, an event is dispatched to the k8s repository. this event runs a job to install kubectl and update the image of the game manager k8s deployment resource in the production environment.

Game Server CI/CD

The same pipeline exists for the game server but with a different event in deployment. After publishing the artifacts to the ghcr, an event is dispatched in the k8s repository to run a job to install kubectl and update the game server image environment variable for the game manager instances.

Game Manager CI/CD action

This is the final Github action to build and deploy the game manager image:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sajjad Rad

Sajjad Rad

Currently a software engineer, always an adventurer