Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@preevy/plugin-github-pr-link

Package Overview
Dependencies
Maintainers
3
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@preevy/plugin-github-pr-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.

latest
npmnpm
Version
0.0.56
Version published
Maintainers
3
Created
Source

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.

FAQs

Package last updated on 03 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts