Github webhooks

In this tutorial, you learn how to set up webhooks to your Github repositories allowing you to automatically update and deploy your plugins in your plentymarkets inbox.

Step 1: Generating a personal access token

First, go to Github and create a new personal access token. This token is used for authenticating your Github account in plentymarkets.

  1. Go to https://github.com/settings/tokens.
  2. Click on Generate new token.
  3. Enter a token description, e.g. the plugin name.
  4. Under Select scopes, activate repo:status to access the commit status.
    → The status is required to inform you about successful or failed deployment of plugins.
  5. Click on Generate token.
    → The personal access token will be generated.
  6. Click on Copy token to copy the token to the clipboard.
    → In the next step, the token will be used instead of your Github password.

Step 2: Adding a plugin

  1. Go to Plugins » Git.
  2. Click on New plugin.
    → The Settings window will open.
  3. Enter the remote URL of your Github repository.
  4. Enter your Github user name.
  5. Paste the copied personal access token into the Password field.
  6. Click on Test connection.
    → The connection to the Github repository is verified and established and a token is generated.
  7. Copy the token to the clipboard.
    → This token is required in step 3.
  8. Select the branch of the repository you want to clone.
  9. Save the settings.
    → The plugin repository is copied to the plentymarkets inbox.

Step 3: Setting up a webhook

Now, go to your Github repository and set up a new webhook for the repository.

  1. Go to Github.
  2. Under Your repositories, click on the plugin repository.
    → The Code tab will open.
  3. Click on the Settings tab.
  4. Click on Webhooks.
  5. Click on Add webhook.
  6. Enter the Payload URL.
    → The payload URL consists of your online store URL and /rest/plugins/hook, e.g. https://www.your-plentystore.co.uk/rest/plugins/hook.
  7. Select application/json from the Content type drop-down menu.
  8. Paste the copied token into the Secret field.
    → This token is used for securing the communication between Github and plentymarkets.
  9. Click on Add webhook.
    → The webhook will be displayed under Webhooks.

Step 4: Checking the webhook

When making changes to your Github repository and committing the changes, your plugin will be updated and deployed automatically via the webhook. Changes will be visible shortly after the commit.

  1. Go to Github.
  2. Under Your repositories, click on the plugin repository.
    → The Code tab will open.
  3. In the list of Commits, the commit is flagged Pending while deploying the plugin.
    → After a short while, Pending will change to Success if updating and deploying was successful or to Failure if the deployment failed.