1. Generate a token
To integrate your Upsun project with an existing GitHub repository, you need to generate a new token. You can generate a classic personal access token, or a fine-grained personal access token for even greater control over the permissions you grant. For the integration to work, your GitHub user needs to have permission to push code to the repository. When you set up or update an integration, it also needs permission to manage its webhooks. This means your user needs to be a repository admin to create the integration. You can remove this permission after setup. Make sure you give your token a description. If you’re generating a classic personal access token, ensure the token has the appropriate scopes based on what you want to do:| Scope | Purpose |
|---|---|
admin:repo_hook | To create webhooks for events in repositories. Always needed. |
public_repo | To integrate with public repositories. |
repo | To integrate with your private repositories. |
repo and read:org | To integrate with private repositories in organizations you belong to. |
| Permission | Access level |
|---|---|
Commit statuses | Read and write |
Contents | Read and write |
Metadata | Read-only |
Pull request | Read and write |
Webhooks | Read and write |
2. Enable the integration
To enable the integration, use either the CLI or the Console.- Using the CLI
- In the Console
Run the following command:
PROJECT_IDis the ID of your Upsun project.OWNER/REPOSITORYis the name of your repository in GitHub.GITHUB_ACCESS_TOKENis the token you generated.GITHUB_URLis the base URL for your GitHub server if you self-host. If you use the publichttps://github.com, omit the--base-urlflag when running the command.
https://github.com/platformsh/platformsh-docs,
the command is similar to the following:| CLI flag | Default | Description |
|---|---|---|
fetch-branches | true | Whether to mirror and update branches on Upsun and create inactive environments from them. When enabled, merging on an Upsun environment isn’t possible. That is, merging environments must be done on the source repository rather than on the Upsun project. See note below for details related to this flag and synchronizing code from a parent environment. |
prune-branches | true | Whether to delete branches from Upsun that don’t exist in the GitHub repository. When enabled, branching (creating environments) must be done on the source repository rather than on the Upsun project. Branches created on Upsun that are not on the source repository will not persist and will be quickly pruned. Automatically disabled when fetching branches is disabled. |
build-pull-requests | true | Whether to track all pull requests and create active environments from them, which builds the pull request. |
build-draft-pull-requests | true | Whether to also track and build draft pull requests. Automatically disabled when pull requests aren’t built. |
pull-requests-clone-parent-data | true | Whether to clone data from the parent environment when creating a pull request environment. |
build-pull-requests-post-merge | false | Whether to build what would be the result of merging each pull request. Turning it on forces rebuilds any time something is merged to the target branch. |
resources-init | false | To specify a resource initialization strategy for new containers. Once set, the strategy applies to all the deployments you launch through your source integration. See more information on available resource initialization strategies. |
fetch-branches and prune-branches options.