> For the complete documentation index, see [llms.txt](https://docs.edgegap.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.edgegap.com/docs/tools-and-integrations/github-actions.md).

# GitHub Actions

Deploy a game server build from GitHub Actions: create the app version, smoke-test it on a real deployment, and promote it, with the Edgegap Deploy Action.

The [Edgegap Deploy Action](https://github.com/edgegap/deploy-action) handles the Edgegap side of a release once your workflow has pushed a new game server image.

1. **Creates an app version** for the new image tag. It copies ports, resources, environment variables, max duration and restart policy from an existing version, so only the image changes. Edgegap first checks it can pull the image.
2. **Smoke-tests it (optional).** It deploys the new version near a location you pick, waits for it to become Ready, and fails the job if the server crashes or restarts within the test window. It then stops the deployment, and stops it as well if the job is cancelled.
3. **Promotes it (optional).** It points an existing version, such as `prod`, at the new image. Your [matchmaker](https://docs.edgegap.com/learn/matchmaking.md) or backend keeps deploying `prod`, so it gets the new build without a config change.

Each run writes a job summary showing the version created, where the smoke test ran, its ports and, on failure, the server's last log lines. It can also record a GitHub Deployment.

## 🚀 Getting Started

**Create the first version yourself**, in the dashboard, with a plugin, or with the [MCP integration](https://docs.edgegap.com/docs/mcp-integration.md), and deploy it once to confirm it works. The action copies that version's settings into every new one.

**Add three repository secrets:**

| Secret                      | Where to find it                                                                    |
| --------------------------- | ----------------------------------------------------------------------------------- |
| `EDGEGAP_API_TOKEN`         | [User Settings / Tokens](https://app.edgegap.com/user-settings?tab=tokens)          |
| `EDGEGAP_REGISTRY_USERNAME` | [Container Registry](https://app.edgegap.com/registry-management/repositories/list) |
| `EDGEGAP_REGISTRY_TOKEN`    | [Container Registry](https://app.edgegap.com/registry-management/repositories/list) |

{% hint style="info" %}
The Edgegap API never returns a version's registry login or secret environment variable values, so the action can't copy them. It asks for them as inputs, and fails before creating anything if one is missing.
{% endhint %}

**Add the action after your image build:**

```yaml
name: Deploy game server
on:
  push:
    branches: [main]
permissions:
  contents: read
  deployments: write
concurrency: edgegap-deploy

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - id: image
        run: |
          echo "name=registry.edgegap.com/my-project/my-game" >> "$GITHUB_OUTPUT"
          echo "tag=$(date -u +%Y%m%d-%H%M)-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"

      - uses: docker/login-action@v3
        with:
          registry: registry.edgegap.com
          username: ${{ secrets.EDGEGAP_REGISTRY_USERNAME }}
          password: ${{ secrets.EDGEGAP_REGISTRY_TOKEN }}

      - uses: docker/build-push-action@v6
        with:
          push: true
          platforms: linux/amd64
          tags: ${{ steps.image.outputs.name }}:${{ steps.image.outputs.tag }}

      - uses: edgegap/deploy-action@v0
        with:
          api-token: ${{ secrets.EDGEGAP_API_TOKEN }}
          application: my-game
          image: ${{ steps.image.outputs.name }}
          tag: ${{ steps.image.outputs.tag }}
          registry-username: ${{ secrets.EDGEGAP_REGISTRY_USERNAME }}
          registry-token: ${{ secrets.EDGEGAP_REGISTRY_TOKEN }}
          base-version: prod
          smoke-test: true
          smoke-near: "50.11,8.68"
          promote-version: prod
```

Use a unique image tag for every build, never `latest`: Edgegap caches images by tag. When you don't name the new version, the action names it by UTC time (`YYYYMMDD-HHMM`).

## ⚙️ Options

| Input             | Default        | Use it to                                                                       |
| ----------------- | -------------- | ------------------------------------------------------------------------------- |
| `base-version`    | newest version | choose which version's settings are copied                                      |
| `version`         | UTC time       | name the new version; re-running with the same name and image reuses it         |
| `version-secrets` |                | set secret environment variables, one `KEY=VALUE` per line                      |
| `smoke-test`      | `false`        | deploy the new version and check that it stays up                               |
| `smoke-near`      | New York       | place the test deployment: `latitude,longitude` or a public IP                  |
| `smoke-duration`  | `60s`          | how long the server must stay Ready without restarting                          |
| `startup-timeout` | `5m`           | how long the first start may take (large images download slowly the first time) |
| `promote-version` |                | point an existing version at the new image once everything passed               |

The [action's README](https://github.com/edgegap/deploy-action#inputs) lists every input and output, including the test deployment's `fqdn` and `ports`. Use those to run a game client test in a later step.

## 💡 Good to Know

* **Rollback** means running the workflow again with the previous image tag and the same `promote-version`.
* **Promoting changes only the image.** Ports, resources and environment variables of the promoted version stay as they are. Change them in the dashboard first if a build needs new ones.
* **A smoke test is a real deployment.** It is billed for about a minute, and on the free tier it uses your one concurrent deployment.
* **A failed build still leaves a version.** Without `promote-version`, nothing deploys it unless asked to by name.
* **Pin the action** to a release (`edgegap/deploy-action@v0.1.0`) or a commit SHA if you want to review updates before they get your API token.
