Thumbnail

Integrate Platform.sh with GitHub

Thumbnail

Campbell Tilley

|

Follow these few steps to setup an integration between Platform.sh and GitHub. Manage your Platform.sh environments directly from GitHub!

By setting up an integration between your Platform.sh project and your GitHub repository, you manage Platform.sh environments directly from Github.

Each time you create and push to a new branch in GitHub, an environment will be created for you in Platform.sh so you can review the branch live on Platform without having to push to an existing environment like Master. Once the environment has been created, each time you push to that branch in GitHub, the environment will be rebuilt. After you merge the branch on GitHub, the environment is deleted on Platform.sh.

To setup this integration for yourself, follow the below steps. The below steps are derived from the Platform.sh docs.

Note that for this integration to work, your GitHub user needs to have permission to push to the repository. You will also need to be the owner of the Platform.sh project.

Generate a token

Firstly, you will need a GitHub token. To create a token, go to your Settings, then select Developer settings and click Personal access tokens. Here you can Generate a new token.

Give it a description and then ensure the token has the following scopes:

  • To integrate with public repositories: public repo
  • To integrate with your own private repositories: repo
  • To integrate with your organisation's private repositories: repo and read:org

Copy the token and make a note of it (temporarily).

Enable the integration

In your terminal, enter the following command to enable the integration.

platform integration:add --type=github --project=PROJECT_ID --token=GITHUB-USER-TOKEN --repository=USER/REPOSITORY

Variables

  • PROJECT_ID : the project ID for your Platform.sh project
  • GITHUB-USER-TOKEN : the token you generated in step 1
  • USER : your github user name
  • REPOSITORY : the name of the repository in github (not the git address)

Add the webhook

If you see the message Failed to read or write webhooks you will need to add the webhook manually.

  1. Copy the hook URL shown in the message.
  2. Go to your GitHub repository and click Settings, select the Webhooks and Services tab, and click Add webhook.
  3. Paste the hook URL, choose application/json for the content type, choose "Send me everything" for the events you want to receive, and click Add webhook.

Your Platform.sh Project is now integrated with your GitHub Repo. You can begin pushing your code to GitHub instead of Platform.sh.

Platform.sh also offers an integration for GitLab. Head over to their documentation for more instructions on how to configure that.

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Comments

  • Allowed HTML tags: <em> <strong> <cite> <blockquote cite> <ul type> <ol start type> <li> <dl> <dt> <dd> <p>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
  • Use [gist:#####] where ##### is your gist number to embed the gist
    You may also include a specific file within a multi-file gist with [gist:####:my_file].

Spread the word