# Deploy your first app > Deploy a GitHub repository to Orchard, get an HTTPS URL, and connect a managed Postgres database. Source: https://docs.orchard.hackclub.com/start/first-deploy/ This guide takes a GitHub repository from code to a running app on your Orchard instance. You connect GitHub, deploy the repository, create a Postgres database, and connect the database to the app. At the end, your app runs on an HTTPS URL and reads its database connection string from a variable. You can follow each step in the dashboard or with the `orchard` CLI. ## Prerequisites - A running Orchard instance that you can sign in to. To set one up, refer to [Install](/start/install/). - A GitHub repository that contains a Dockerfile, or an app that Orchard can detect and build without one. - For private repositories, a GitHub App on the instance. To create one, refer to [Connect a GitHub App](/operate/finishing-setup/#connect-a-github-app). - For the CLI steps, the `orchard` CLI. To install it, refer to [Use the CLI](/cli/). ## 1. Connect GitHub Orchard needs access to your GitHub account to list your repositories and to deploy again on each push. For a public repository, you can skip this step. **Dashboard** 1. Open your account menu. 2. Select **Account settings** > **Connections**. 3. In **GitHub**, select **Connect**. 4. Approve the request on GitHub. 5. In **Repository access**, select **Add account**. 6. Install the GitHub App on the account that owns your repository. **CLI** 1. Sign in to your instance: ```sh orchard auth login --api-url https://orchard.example.com ``` 2. Link your GitHub account: ```sh orchard github link --open ``` 3. Install the GitHub App on the account that owns your repository: ```sh orchard github install --open ``` ## 2. Deploy the app Orchard clones the repository, builds an image on your cluster, and starts the app. **Dashboard** 1. Open a project. 2. Select **New app**. 3. In **Start from scratch**, select **GitHub repo**. 4. In **Repository**, select your repository. For a public repository, paste `owner/repo` into the search field. 5. In **Branch**, select a branch. 6. In **Name**, enter a name for the app. 7. In **Networking**, confirm that the port matches the port your app listens on. 8. In **Reach**, select **Public link** for a URL that anyone can open. The default, **Private link**, requires people to sign in to Orchard. 9. Select **Deploy**. Orchard opens a progress page with these steps: **Starting the builder**, **Cloning the repo**, **Building the image**, **Pushing the image**, and **Rolling out**. The build logs stream on the same page. **CLI** 1. In your project directory, link the directory to an Orchard project: ```sh orchard link ``` 2. Create the app and wait for the first build: ```sh orchard deploy create --github owner/repo#main --name web --port 3000 --wait ``` The CLI generates a URL that requires people to sign in to Orchard. To make the URL public, refer to [Protect an app](/deploy/protection/). The app is live when its status is **Running**. Its URL appears in the header of the app page. A new URL can show a certificate warning for up to a minute, until its certificate is issued. If the build fails, refer to [Builds](/deploy/builds/#troubleshoot-a-failed-build). ## 3. Create a database A managed database is a Postgres instance with its own backups. It has its own lifecycle, separate from any app that connects to it, so a redeploy of the app does not change it. **Dashboard** 1. Open the project. 2. Select **New app**. 3. In **Start from scratch**, select **Postgres**. 4. In **Database name**, enter a name. 5. Select **Create database**. **CLI** ```sh orchard db create --name appdb --wait ``` ## 4. Connect the database to the app Connect the database with [a reference](/deploy/connect-resources/) instead of a copied connection string. A reference follows the database through a password rotation or a restore, so the app keeps working without an edit. **Dashboard** 1. Open the app. 2. Go to **Variables**. 3. Add a variable named `DATABASE_URL`. 4. In the value field, select **Use a resource**. 5. Select your database. 6. Select **Save**. **CLI** ```sh orchard deploy bindings add --database appdb ``` This command adds `DATABASE_URL` to the app. Orchard restarts the app with the new variable. ## Next steps At this point, your app runs on an HTTPS URL with a Postgres database behind it. To put it on your own domain, [add a custom domain](/deploy/domains/). To deploy on every push, [set up auto-deploy](/deploy/github/#auto-deploy). ## Related resources - [Set variables](/run/environments/) - Set variables for one app, or share them across an environment. - [Roll back an app](/deploy/rollbacks/) - Go back to an earlier build, and restore bound databases with it. - [Deploy from your terminal](/deploy/deploy-from-terminal/) - Deploy a local folder with `orchard up`, without a repository. - [Read logs and open a shell](/run/logs/) - Search the logs of an app and open a shell in a running container.