0.0.56 • Published 6 months ago

@preevy/plugin-github-pr-link v0.0.56

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
6 months ago

GitHub Pull Request link

This plugin allows showing the Preevy environment URLs in a GitHub PR comment. The comment is added/updated at the up command and deleted in the down command.

Demo comment

Configuration

Add the plugin to the plugins section of the x-preevy element in your Docker Compose file:

services:
  ...
x-preevy:
  plugins:
    - module: '@preevy/plugin-github-pr-link'
    # detect: false
    # disabled: true
    # commentTemplate: see below
    # pullRequest: PR number
    # token: GitHub token
    # repo: GitHub repo (owner/reponame)

At runtime, the plugin will attempt to detect the configuration it needs from environment variables and the git context. Flags can be specified in the up and down commands to override the behaviour.

Environment variableFlagConfig sectionOther sources
GitHub tokenGITHUB_TOKEN--github-pr-link-tokentoken
Repo (owner/reponame)GITHUB_REPOSITORY--github-pr-link-repocommentTemplategit context (if detect is not false)
PR numberGITHUB_REF--github-pr-link-pull-requestpullRequest
Comment template--github-pr-link-comment-template-filecommentTemplate

Comment template

The generated PR comment can be customized by specifying a template (see above table). The template is rendered by nunjucks and receives a context containing a urls property which is one of the following:

  • undefined: The environment is being deleted, or the unlink command has been invoked.
  • Otherwise, the result of the preevy urls command: an array of { service: string; port: number; url: string; project: string }

Here is an example of a configuration file containing a customized template:

x-preevy:
  plugins:
  - module: '@preevy/plugin-github-pr-link'
    commentTemplate: |
      {% if urls %}[Preevy](https://preevy.dev) has created a preview environment for this PR.

      Here is how to access it:

      | Service | Port | URL |
      |---------|------|-----|
      {% for url in urls %}| {{ url.service }} | {{ url.port }} | {{ url.url }} |
      {% endfor %}
      {% else %}The [Preevy](https://preevy.dev) preview environment for this PR has been deleted.
      {% endif %}

CI providers

The plugin can auto detect its configuration from the CI providers supported by @preevy/core:

To disable auto-detection, specify detect: false at the plugin configuration in the Docker Compose file.

Commands

This plugin adds the following commands:

github-pr link: Creates the comment from an existing Preevy environment

github-pr unlink: Deletes the comment from a Preevy environment.

The commands accept a similar set of flags as described above. Run preevy github-pr link --help for details.

Disabling the plugin

The plugin can be disabled by specifying disabled: true at the plugin configuration in the Docker Compose file, adding the environment variable PREEVY_GITHUB_LINK=0 or specifying the flag --github-pr-link-enabled=no in the up and down commands.

0.0.49-alpha.0

10 months ago

0.0.46-alpha.0

10 months ago

0.0.40

10 months ago

0.0.41

10 months ago

0.0.42

10 months ago

0.0.43

10 months ago

0.0.44

10 months ago

0.0.45

10 months ago

0.0.46

10 months ago

0.0.47

10 months ago

0.0.37

11 months ago

0.0.38

11 months ago

0.0.39

11 months ago

0.0.36

11 months ago

0.0.48-alpha.0

10 months ago

0.0.40-alpha.18

10 months ago

0.0.45-alpha.0

10 months ago

0.0.51

8 months ago

0.0.52

8 months ago

0.0.53

8 months ago

0.0.55

7 months ago

0.0.56

7 months ago

0.0.50

9 months ago

0.0.48

10 months ago

0.0.49

9 months ago

0.0.50-pkg.9c1ef19

9 months ago

0.0.47-alpha.0

10 months ago

0.0.44-alpha.0

10 months ago

0.0.35

11 months ago

0.0.34

12 months ago

0.0.33

12 months ago

0.0.32

12 months ago

0.0.31

12 months ago

0.0.30

12 months ago

0.0.30-alpha.0

12 months ago

0.0.29-alpha.0

12 months ago