# Connect GitHub > How to connect GitHub with the GitHub App, in a few clicks, or with a personal token, for private repositories, deploy on every push and previews. The panel uses the GitHub connection to clone private repositories, deploy on every push and comment on pull requests with the preview address. Public repositories work without a connection for manual deploys. ## Two ways to connect | | GitHub App (recommended) | Personal token | |---|---|---| | How you connect | Click **Connect GitHub**, pick the repositories in GitHub and come back connected | Create a token in GitHub and paste it into the panel | | Repositories | Only the ones you pick in the installation | The ones the token can see | | Deploy on every push | Already on through the App, with no webhook per repository | The panel creates a webhook in each repository | | Expiration | The panel generates a 1-hour access each time it's used: nothing to expire | The token expires on the date you picked | | PR comment | Shows up as `ployter[bot]` | Shows up as your account | Use a token only if your organization doesn't allow installing apps. ## Connect with the GitHub App (recommended) In the panel, you need the **Manage GitHub credentials** permission. By default, owners and admins have it. 1. In the panel, open **Integrations → GitHub** and click **Connect GitHub**. 2. GitHub opens and asks where to install the App: on your account or on an organization where you're an admin. 3. Pick **All repositories** or **Only select repositories** and check the repositories the panel will use. 4. Click **Install** (or **Install & Authorize**). GitHub asks you to authorize Ployter to confirm who you are: click **Authorize**. 5. GitHub sends you back to the panel, and the connection shows up in the list with the **App** badge, the account name and the number of services using it. Before saving, the panel checks that the installation belongs to the account that came back from GitHub. No token is stored: for each clone, repository listing or comment, the panel generates an access that lasts 1 hour and only sees the repositories you picked. ![GitHub screen in the panel with a GitHub App connection](https://ployter.com/assets/docs/en/github-app-list.webp) ### Organizations If you're not an admin of the organization, GitHub sends an installation request to its admins. The panel shows **Request sent**. When an admin approves it in GitHub, click **Connect GitHub** again and pick the organization. ### More than one team The same installation can be used in several teams in the panel. Open the other team and click **Connect GitHub**: on the account where the App is already installed, GitHub opens the installation settings. Click **Save** and you're back in the panel, connected. If you manage GitHub in both teams, there's a shorter path: on the other team's **GitHub** page, the **Use a connection from another team** card lists the accounts already connected in your teams. Click **Use here** and you're done, without going through GitHub. ![Use a connection from another team card on the GitHub page](https://ployter.com/assets/docs/en/github-reuse.webp) The repositories you picked apply to every team that uses the installation. To keep them separate, use different GitHub accounts or organizations. ## Change repositories or uninstall In the **Integrations → GitHub** list, click the connection's link icon (**Manage on GitHub**). It opens the installation page in GitHub, where you: - add or remove repositories in **Repository access** and click **Save** (the panel's list updates by itself); - uninstall the App in **Uninstall**. The connection is removed from the panel in every team that used it. ## Connect with a personal token GitHub has two kinds of personal token. Both work: | | Classic | Fine-grained | |---|---|---| | Where to create | https://github.com/settings/tokens | https://github.com/settings/personal-access-tokens | | Reach | Every repository your account can access | Only the repositories you choose | | Permissions | `repo` and `admin:repo_hook` scopes | **Contents** (read), **Metadata** (read) and **Webhooks** (read and write) | | Starts with | `ghp_` | `github_pat_` | ### Classic token 1. In GitHub, open **Settings → Developer settings → Personal access tokens → Tokens (classic)**. 2. Click **Generate new token → Generate new token (classic)**. 3. In **Note**, enter a name, for example `ployter`. 4. In **Expiration**, pick the duration. When the token expires, the panel stops cloning until you replace it. 5. Check the scopes: - `repo` (access to repositories, including private ones); - `admin:repo_hook` (create and remove the deploy-on-push webhook). 6. Click **Generate token** and copy the token. It is shown only once. > [!NOTE] > If the organization uses SSO (SAML), authorize the token for it: in the token list, click **Configure SSO** next to the token and **Authorize** for the organization. ### Fine-grained token 1. In GitHub, open **Settings → Developer settings → Personal access tokens → Fine-grained tokens**. 2. Click **Generate new token**. 3. Enter a name and pick the duration in **Expiration**. 4. In **Resource owner**, pick your account or the organization that owns the repositories. Some organizations require an admin's approval before the token works. 5. In **Repository access**, pick **Only select repositories** and check the repositories the panel will use (or **All repositories**). 6. In **Permissions → Repository permissions**, set: - **Contents**: Read-only; - **Metadata**: Read-only (already selected); - **Webhooks**: Read and write; - **Pull requests**: Read and write, for the preview comment. 7. Click **Generate token** and copy the token. ### Add the token 1. In the panel, open **Integrations → GitHub** and click **Use a token** (or **New credential**, if the GitHub App isn't available). 2. Enter a **Name** (for example, `GitHub Acme`). 3. Paste the **Token**. 4. Click **Save**. The panel checks the token with GitHub before saving and stores it encrypted. ![GitHub credentials screen with the New credential modal](https://ployter.com/assets/docs/en/github-new-credential.webp) ## Use the connection in a service When you create a service with the **GitHub** source: 1. In **Repository**, use **Pick from the list**. The list shows each connection's repositories, grouped, tagged **private** or **public**. 2. In **GitHub credential**, pick the connection. **None (public repository)** only works for a public repository. On an existing service, change it in **Settings → Source → Credential**. See [Projects and services](https://ployter.com/en/docs/services/projects-and-services/). ## Deploy on every push With **Deploy on every push** turned on in the service (in **Settings → Source**), each push to a branch deploys every service with deploy on every push that uses that repository and branch. Tag pushes and deleted branches are ignored. GitHub's calls are signed, and the panel rejects calls without the right signature. - **GitHub App:** there's nothing to configure. The App already receives the **push** and **pull_request** events from every repository in the installation. - **Token:** the panel creates a webhook in the repository by itself, which shows up in the repository's **Settings → Webhooks** in GitHub. In **Recent Deliveries** you see each call and the panel's response. When no service uses the repository with deploy on every push or previews anymore, the panel removes the webhook. > [!WARNING] > With a token that lacks webhook permission, manual deploys work, but deploy on every push isn't turned on automatically. The service shows a warning like *"Automatic deploy: could not create the webhook on acme/loja (the token doesn't have webhook permission (admin:repo_hook))"*. Fix the token or move the service to a GitHub App connection. If you move a service from a token to the GitHub App, the repository's old webhook may still be there. The panel ignores the repeated call, so the deploy happens only once. If you want, delete the old webhook in **Settings → Webhooks**. ## Replace the token This applies only to token connections. When the token expires or is revoked, cloning fails with *"GitHub rejected the token (invalid or expired). Replace it in Integrations › GitHub."* 1. Generate a new token in GitHub, with the same permissions. 2. In **Integrations → GitHub**, click the credential's pencil (**Edit credential**). 3. Paste the new token and click **Save**. Leave the field blank to keep the current one. Services that use the credential switch to the new token, with no other change. GitHub App connections have no token to replace. ## Remove the connection Click the connection's trash icon and confirm with **Remove**. Services that used it are left without it: a private repository stops cloning until you pick another connection in the service. The modal tells you how many services are affected. - **GitHub App:** the connection is removed only from this team; the App stays installed in GitHub. To remove access for good, uninstall it in **Manage on GitHub**. - **Token:** webhooks already created in the repositories stay there. To delete them, open **Settings → Webhooks** in the GitHub repository. Also revoke the token in GitHub if it's no longer used. ## Copy from another team If you own another team that already has connections, click **Import from another team**. Both GitHub App and token connections are copied. The other owners of the source team get an email about the copy.