0.0.63 • Published 3 days ago

@preevy/plugin-github v0.0.63

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
3 days ago

GitHub integration plugin

The @preevy/plugin-github plugin adds GitHub integration to Preevy.

This plugin is bundled with Preevy and enabled by default. To disable it, see below.

GitHub PR comment for your environment

Demo comment

Automatic comment at up and down

Comment generation is done as part of the up and down core commands.

If a GitHub context is detected (e.g, when running in a GitHub actions job), it will post the comment automatically.

Manual comment using the github commands

This plugin adds the following commands:

github pr comment: Creates a GitHub PR comment for an existing Preevy environment. If the comment exists, it is updated with the current set of URLs.

github pr uncomment: Updates the GitHub PR comment to state that the Preevy environment has been deleted.

Run preevy github pr comment --help for details.

Configuration

At runtime, the plugin will attempt to detect the configuration it needs from environment variables and the git context. Options can be overridden using CLI flags and the Docker Compose file.

Environment variableFlagConfig sectionOther sources
GitHub tokenGITHUB_TOKEN--github-tokentoken
Repo (owner/reponame)GITHUB_REPOSITORY--github-reporepogit context (if detect is not false)
PR numberGITHUB_REF (format: refs/pull/<number>)--github-pull-requestpullRequest
Comment template--github-pr-comment-template-filecommentTemplate

Configuration from the CI provider context

The plugin can automatically detect its configuration when running in a CI provider supported by @preevy/core:

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

Configuration from the Docker Compose file

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'
    # detect: false
    # disabled: true
    # commentTemplate: see below
    # pullRequest: PR number
    # token: GitHub token
    # repo: GitHub repo (owner/reponame)

Configuration from CLI flags

The following flags can be specified at the Preevy CLI:

Comment template

The generated PR comment can be customized by specifying a template in your Docker Compose file, or in a separate file (see above). 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 uncomment 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'
    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 %}

Disabling the plugin

Disabling the plugin completely (will remove all the GitHub integration)

Any of the following will disable the plugin:

  • Specify disabled: true at the plugin configuration in the Docker Compose file
  • Set the PREEVY_DISABLE_PLUGINS environment variable to @preevy/plugin-github. If multiple plugins need to be disabled, specify a comma-separated list of modules.
  • Add the flag --disable-plugin=@preevy/plugin-github

Disabling the GitHub PR comment

Automatic commenting on the GitHub PR can be disabled by, setting the environment variable PREEVY_GITHUB_PR_COMMENT_ENABLED=0 or specifying the flag --github-pr-comment-enabled=no at the up and down commands.

0.0.63

3 months ago

0.0.62

3 months ago

0.0.61

4 months ago

0.0.60

4 months ago

0.0.59

5 months ago

0.0.59-esm.7666178

5 months ago

0.0.58

5 months ago

0.0.57

6 months ago

0.0.56

6 months ago