# Deploy to the edge - Editor

<WizardSteps build="gateway" method="local" step="deploy-to-the-edge" />

<MethodTabs build="gateway" method="local" step="deploy-to-the-edge" />

In this guide we'll deploy your locally-developed gateway to the edge, at over
300 data-centers around the world. Zuplo deploys from Git source control — once
your project is connected to a GitHub repository, every push deploys
automatically, with no CI/CD configuration required.

The act of deployment creates new
[environments](../../../articles/environments.mdx), so it's worth familiarizing
yourself with [how environments work](../../../articles/environments.mdx).

To follow this tutorial, you need a [GitHub account](https://github.com) and a
Zuplo account. Your local project directory must also be linked to a hosted
Zuplo project in the Portal. The local files alone cannot receive a deployment.

<Stepper>

1. **Create and link a hosted project if needed**

   If you answered **Yes** when `create-zuplo-api` asked to create a matching
   Portal project, the CLI already created and linked its hosted project.
   Otherwise, from your local project directory, create one and link its working
   copy:

   ```bash
   npx zuplo project create --name example-project
   npx zuplo link
   ```

   Sign in and select your Zuplo account when prompted. If you already created a
   hosted project in the Portal, run only `npx zuplo link` and select that
   project and its working copy. See
   [Creating a matching portal project](../../../cli/create-zuplo-api.mdx#creating-a-matching-portal-project).

2. **Check your project status**

   From your project directory, run `zuplo info` to see how your local project
   maps to Zuplo:

   ```bash
   npx zuplo info
   ```

   ```bash
   Project: example-project
   Account: your-account
   Portal: https://portal.zuplo.com/your-account/example-project
   Environment Type: working-copy
   Source Control: none, connect at https://portal.zuplo.com/your-account/example-project/settings/source-control-settings
   ```

   Notice the **Source Control** line shows `none` — your project isn't
   connected to a repository yet. The next steps walk through connecting one so
   your changes deploy automatically.

3. **Create a GitHub repository**

   In GitHub, [create a new repository](https://github.com/new). Leave it
   **empty** — don't add a README, `.gitignore`, or license — since your project
   already contains those files.

4. **Push your project to GitHub**

   `create-zuplo-api` already initialized your project as a Git repository.
   Stage and commit your work (if you haven't already), then point your local
   repo at the new GitHub repository and push:

   ```bash
   git add .
   git commit -m "Initial commit"
   git remote add origin https://github.com/your-account/example-project.git
   git branch -M main
   git push -u origin main
   ```

5. **Connect the repository in Zuplo**

   Open the source-control settings link from the `zuplo info` output, or in the
   Zuplo Portal open **Settings → Source Control**.

   If this is your first time, click **Connect to GitHub** and authorize the
   Zuplo GitHub app — see
   [GitHub Setup](../../../articles/source-control-setup-github.mdx) for a
   detailed walkthrough of the authorization flow and permissions.

   Once the app has access to your repositories, find the repository you just
   pushed to in the list and click **Connect**.

   :::note{title="Non-empty repository warning"}

   Because you already pushed your project, the portal will show a dialog
   warning that the repository isn't empty and that connecting will only create
   an association — no changes will be pushed or pulled automatically. That's
   exactly what we want here, so click **Connect** to proceed.

   :::

6. **Verify your deployment**

   As soon as the repository is connected, Zuplo deploys your `main` branch. In
   GitHub you'll see a status check next to your commit; when it succeeds, the
   deployment links to your new environment.

   Run `zuplo info` again to confirm your project is now connected to source
   control:

   ```bash
   npx zuplo info
   ```

   :::tip{title="Branch environments"}

   Every branch you push gets its own isolated environment. Create a
   `development` branch, push it, and Zuplo deploys a matching environment
   automatically. See
   [Branch-Based Deployments](../../../articles/branch-based-deployments.mdx) to
   learn how branches map to environments.

   :::

</Stepper>

<TutorialPager build="gateway" method="local" step="deploy-to-the-edge" />
