Skip to main content
Engineering

Not translated yet — showing English.

Deployment

Deployment shows where your project serves players, and which of those locations need attention. It puts the PlayServ network on a map and in a table of points of presence, each with its live sessions and the health of the game-server replicas running there. It is an overview: the footprint itself is changed in Servers, and every location links you there.

Video overview · 0:29

A quick tour of the screens on this page and how they fit together.

The video covers the essentials only. For every setting, limit and edge case, read the page below.


Points of presence

A point of presence (PoP) is a PlayServ location where game servers can run, such as Frankfurt, shown as FRA. The same code is used wherever a location appears: on this map, in a fleet's regions, and when you choose deployment points for a machine pool.

StatusMeaning
ActiveConfigured for this project and serving players.
No trafficConfigured for this project, but no sessions are routed to it right now.
AvailablePart of the PlayServ network, but not configured for this project.

A room's region is your label, not its location

A room counts toward the PoP of the game server that hosts it. The region string your server reports for a room is shown in Game Rooms as you sent it, and Deployment never uses it.

Every PoP carries the conditions that explain its state. The table sorts locations so the ones needing action come first.

ConditionSeverityMeaning
Replica(s) unhealthyProblem"X of Y replicas unhealthy": they are running, but their health checks are failing.
Machine pool errorProblemA machine pool at this location reported an error; the detail names the fleet and the reason.
N replicas drainingNoticeReplicas are finishing their sessions before shutting down.
No active sessionsNoticeThe location is provisioned, but no traffic is routed to it.
Healthy—Nothing to report.

Draining is not a fault

Draining replicas are a controlled shutdown: they stop taking new sessions and let the current ones finish. They show as a notice, not a problem, and need no action.


Reading the page

BlockWhat it tells you
Situation stripActive PoPs and active sessions; then either N locations need attention, with a chip per location naming its cause, or All locations operating normally; then how many replicas are serving.
MapEvery PoP with published coordinates. Active pins show their code, available ones a dot, and arcs join the busiest PoP to the others. Hover a pin for its sessions, fleets and top conditions. Hide available locations leaves only the ones your project uses.
Points of presenceOne row per location: Location (city and code), Condition (the primary one, plus "+N more"), Sessions, and Serving capacity ("X / Y healthy", with unhealthy and draining counts). A location without coordinates is marked no coordinates published and is missing from the map.

A location hosting part of a multi-location fleet shows its sessions as "up to N".

Each row leads to where you can act on it.

ClickOpens
An active PoPThe fleet that serves it, on its Rooms tab in Servers.
An available PoPDeployment points, with that location in focus, to add it to a fleet.

Branch deploys

Bind a branch to an environment, and every push to it deploys your functions and game servers there. The deploy runs as a GitHub Action in your repository: it asks PlayServ which environment the branch is bound to, then deploys with the PlayServ CLI. The bindings live in PlayServ, never in the repository.

Connect the repository and bind branches

In Project settings → Deployment, connect the repository and bind each branch to the environment it deploys to.

SettingWhat it does
RepositoryThe GitHub organisation or user, repository name and default branch. PlayServ stores these only, never GitHub credentials.
Branch → environment bindingsWhich environment each branch deploys to. A branch deploys to one environment; several branches can deploy to the same one. A disabled binding stays, but its pushes deploy nothing. A copied environment has to be re-linked before it can be bound.

Create a server key for each environment

Create a Server API key in every environment a branch deploys to. A key deploys only to its own environment.

Add the secrets to GitHub

In the repository's Settings → Secrets and variables → Actions:

NameKindValue
PLAYSERV_HOSTVariableThe PlayServ platform URL, <platform-url>.
PLAYSERV_SERVER_KEYSecretA server key. Enough when every bound branch deploys to the same environment.
PLAYSERV_SERVER_KEY_<ENV>SecretOne more key per environment, named after it in capitals with - as _: environment qa-2 → PLAYSERV_SERVER_KEY_QA_2. List each one in the workflow's env: block.

Add the workflow

Save the workflow below as .github/workflows/deploy.yml and push it.

What a push does

The pushed branchWhat happens
Not bound, or its binding is disabledNothing: the job ends successfully.
Bound to an environmentEvery cloud function in the repository (each folder with a platform.json) is deployed to that environment with playserv publish.
…with a game server that's new in that environmentThe game server is registered with default room settings and a machine pool of 0 machines, and its image is pushed. Nothing starts until you raise the pool's size in Servers.
…with a game server that already has a poolThe pool is rolled onto the new image.

Rolling a pool closes its rooms

Each machine of the pool is replaced, and the rooms on it close with their players. Bind a branch you push deliberately, not a busy one.

Deploys from one repository run one at a time. The name in each platform.json must be the function's slug in your project. A failed deploy fails the job, with the reason in the Actions log.

The workflow

# PlayServ auto-deploy: push to a bound branch, and the functions and game
# servers in this repo deploy to that branch's environment.
# Copy this file into your repo at .github/workflows/deploy.yml.
#
# Repository variable (Settings → Secrets and variables → Actions → Variables):
#   PLAYSERV_HOST              — the PlayServ platform URL
# Repository secrets:
#   PLAYSERV_SERVER_KEY        — a server key; enough when every bound branch
#                                targets the same environment
#   PLAYSERV_SERVER_KEY_<ENV>  — one per additional environment, uppercased, '-' → '_'
#                                (environment "qa-2" → PLAYSERV_SERVER_KEY_QA_2); list
#                                each one in the step's `env:` block below
#
# The branch → environment bindings live in PlayServ (Project settings → Deployment),
# never in this repo.

name: Auto-deploy to PlayServ

on:
  push:
    branches: ['**']   # every branch (not tags) — the binding in PlayServ decides

# One deploy at a time per repo: two pushes must never roll a pool at once, and two
# branches bound to the same env would otherwise race on a first registration.
concurrency:
  group: playserv-deploy-${{ github.repository }}
  cancel-in-progress: false

jobs:
  deploy:
    runs-on: ubuntu-latest   # curl, jq and Docker (with buildx) are preinstalled
    steps:
      - uses: actions/checkout@v4

      - name: Resolve branch mapping and deploy
        env:
          PLAYSERV_HOST: ${{ vars.PLAYSERV_HOST }}
          PLAYSERV_SERVER_KEY: ${{ secrets.PLAYSERV_SERVER_KEY }}
          # Multi-env repos: expose each env's key so the script can pick by name.
          # PLAYSERV_SERVER_KEY_DEV: ${{ secrets.PLAYSERV_SERVER_KEY_DEV }}
          # PLAYSERV_SERVER_KEY_PROD: ${{ secrets.PLAYSERV_SERVER_KEY_PROD }}
        run: |
          set -euo pipefail
          BRANCH="${GITHUB_REF_NAME}"

          # ── 1. exchange any held key for a session (reading the bindings works with any environment's key)
          bootstrap_key="${PLAYSERV_SERVER_KEY:-}"
          if [ -z "$bootstrap_key" ]; then
            first_var=$(env | sed -n 's/^\(PLAYSERV_SERVER_KEY_[A-Z0-9_]*\)=.*/\1/p' | head -1)
            [ -n "$first_var" ] && bootstrap_key="${!first_var}"
          fi
          if [ -z "$bootstrap_key" ]; then
            echo "::error::no PLAYSERV_SERVER_KEY / PLAYSERV_SERVER_KEY_<ENV> secret is configured"
            exit 1
          fi

          # --fail-with-body keeps the platform's problem+json detail on errors
          # (a bare curl -f would swallow it and report only an opaque exit 22).
          exchange() {
            local resp
            # Send an explicit zero Content-Length: a bodyless POST can be rejected with 411.
            if ! resp=$(curl -sS --fail-with-body -X POST "$PLAYSERV_HOST/api/v1/auth/cli" \
                -H "Authorization: Bearer $1" -H "Content-Length: 0"); then
              echo "::error::auth/cli failed: $resp" >&2
              return 1
            fi
            printf '%s' "$resp"
          }
          session=$(exchange "$bootstrap_key")
          token=$(jq -r .access_token <<<"$session")
          project_id=$(jq -r .project_id <<<"$session")
          key_env=$(jq -r .env <<<"$session")

          # ── 2. fetch the branch→environment binding from PlayServ
          branch_q=$(jq -rn --arg v "$BRANCH" '$v|@uri')
          mapping=$(curl -sS --fail-with-body \
            "$PLAYSERV_HOST/api/v1/projects/$project_id/branch-env-bindings?branch=$branch_q" \
            -H "Authorization: Bearer $token") \
            || { echo "::error::mapping fetch failed: $mapping"; exit 1; }
          target_env=$(jq -r '[.data[] | select(.enabled)][0].env_name // empty' <<<"$mapping")

          if [ -z "$target_env" ]; then
            echo "branch '$BRANCH' is not mapped to an environment — nothing to deploy"
            exit 0
          fi
          echo "branch '$BRANCH' deploys to environment '$target_env'"

          # ── 3. one server key per environment: use the key whose environment matches
          deploy_key="$bootstrap_key"
          deploy_session="$session"
          if [ "$key_env" != "$target_env" ]; then
            env_var="PLAYSERV_SERVER_KEY_$(tr '[:lower:]-' '[:upper:]_' <<<"$target_env")"
            deploy_key="${!env_var:-}"
            if [ -z "$deploy_key" ]; then
              echo "::error::branch '$BRANCH' maps to env '$target_env' but no $env_var secret is configured (one deploy key per env)"
              exit 1
            fi
            deploy_session=$(exchange "$deploy_key")
            key_env=$(jq -r .env <<<"$deploy_session")
            if [ "$key_env" != "$target_env" ]; then
              echo "::error::secret $env_var holds a '$key_env' key, not a '$target_env' key"
              exit 1
            fi
          fi
          api_token=$(jq -r .access_token <<<"$deploy_session")
          project_slug=$(jq -r .project_slug <<<"$deploy_session")

          # PlayServ API call in the mapped environment: the body lands in $RESP, the HTTP
          # status is printed (so a 404 is an answer here, not a curl failure).
          RESP=$(mktemp)
          api() {
            local args=(-sS -o "$RESP" -w '%{http_code}' -X "$1" "$PLAYSERV_HOST$2"
              -H "Authorization: Bearer $api_token"
              -H "X-Project-Slug: $project_slug" -H "X-Env: $target_env")
            if [ $# -ge 3 ]; then args+=(-H "Content-Type: application/json" --data "$3"); fi
            curl "${args[@]}"
          }

          # ── 4. sort the manifests: functions go to `publish`, game servers never do
          functions=()
          servers=()
          while IFS= read -r manifest; do
            dir=$(dirname "$manifest")
            name=$(jq -r '.name // empty' "$manifest")
            [ -n "$name" ] || name=$(basename "$dir")
            kind=$(jq -r '.kind // "cloud_function"' "$manifest")
            if [ "$kind" = game_server ]; then
              servers+=("$name|$dir")
            else
              functions+=("$name")
            fi
          done < <(find . -name platform.json -not -path '*/bin/*' -not -path '*/obj/*' \
                     -not -path './.git/*' | sort)

          # ── 5. hand the functions to the CLI: it vendors shared projects into each
          #      bundle, uploads, and polls
          curl -fsSL "$PLAYSERV_HOST/api/v1/cli/download?rid=linux-x64" -o playserv
          chmod +x playserv
          # Talk to the same platform the CLI was downloaded from.
          export PLAYSERV_API_URL="$PLAYSERV_HOST"
          ./playserv login "$deploy_key"
          # The CLI's exit code (0 only if every function deployed) passes or fails the job.
          if [ ${#functions[@]} -gt 0 ]; then
            only=()
            for slug in "${functions[@]}"; do only+=(--only "$slug"); done
            ./playserv publish "${only[@]}" --env "$target_env" --yes
          else
            echo "no cloud functions in this repo"
          fi

          # ── 6. game servers: first push registers, later pushes roll the pool's image
          tag="${GITHUB_SHA::12}"
          room_config='{"capacity":16,"reservation_ttl_seconds":20,"room_lifetime_seconds":86400,"room_idle_timeout_seconds":60,"max_rooms":20}'
          for entry in "${servers[@]}"; do
            slug=${entry%%|*}
            dir=${entry#*|}

            # A server's own Dockerfile is written against its solution folder
            # (it copies nuget.config and the project from there); without one
            # the CLI writes a Dockerfile for the server folder itself.
            build=(--src "$dir")
            if [ -f "$dir/Dockerfile" ]; then
              context=$dir
              while [ "$context" != . ] && ! compgen -G "$context/*.sln*" >/dev/null; do
                context=$(dirname "$context")
              done
              build=(--src "$context" --dockerfile "$dir/Dockerfile")
            fi

            q=$(jq -rn --arg v "$slug" '$v|@uri')
            code=$(api GET "/api/v1/functions?kind=game_server&q=$q&limit=100")
            if [ "$code" != 200 ]; then
              echo "::error::could not read game server '$slug' in '$target_env' (HTTP $code): $(cat "$RESP")"
              exit 1
            fi
            state=$(jq -r --arg s "$slug" '[.data[] | select(.slug == $s)][0] | if . == null then "absent" elif .executor_run == "platform-pooled" and .status != "deleted" and .status != "disabled" then "pooled" else "\(.status) / \(.executor_run // "unknown")" end' "$RESP")

            case "$state" in
              pooled)
                echo "game server '$slug': rolling its pool to $tag"
                ./playserv image push --slug "$slug" "${build[@]}" --tag "$tag" --roll --env "$target_env"
                ;;
              absent)
                echo "game server '$slug' is new in '$target_env': registering it with a pool of 0 machines"
                ./playserv functions declare "$slug" --kind game_server \
                  --hosting-mode multi-room --description playserv-autodeploy --env "$target_env"
                code=$(api GET "/api/v1/functions?kind=game_server&q=$q&limit=100")
                fn_id=$(jq -r --arg s "$slug" '[.data[] | select(.slug == $s)][0].id // empty' "$RESP")
                if [ "$code" != 200 ] || [ -z "$fn_id" ]; then
                  echo "::error::'$slug' was declared but could not be read back (HTTP $code)"
                  exit 1
                fi
                code=$(api PUT "/api/v1/functions/$fn_id/room-config" "$room_config")
                if [[ $code != 2?? ]]; then
                  echo "::error::room configuration for '$slug' refused (HTTP $code): $(cat "$RESP")"
                  exit 1
                fi
                ./playserv image push --slug "$slug" "${build[@]}" --tag "$tag" --env "$target_env"
                pool=$(jq -cn --arg v "$tag" '{desired_size: 0, rooms_per_machine: 1, image_version: $v}')
                code=$(api PUT "/api/v1/machine-pools/$slug" "$pool")
                if [[ $code != 2?? ]]; then
                  echo "::error::pool for '$slug' refused (HTTP $code): $(cat "$RESP")"
                  exit 1
                fi
                echo "::notice::game server '$slug' registered in '$target_env' with a pool of 0 machines on $tag — raise its size in the Backoffice (Engineering → Servers)"
                ;;
              *)
                echo "::error::game server '$slug' exists in '$target_env' as '$state' (status / executor_run) — this workflow only registers a new server or rolls a pooled one. Finish it by hand in the Backoffice or with the PlayServ MCP (declare, room configuration, pool), or rename it in platform.json."
                exit 1
                ;;
            esac
          done

Next steps

  • Servers — fleets, replicas, machine pools, and choosing deployment points
  • Game Rooms — the live rooms these locations serve
  • Platform Health — whether the PlayServ platform itself is healthy in each location

Last updated on 22 Oct 2026