Giter VIP home page Giter VIP logo

env-changes-detector's Introduction

Detect changes in env files

Github action for detecting changes in env files. Useful for adding comments to PRs with changes to environment variables and more (see outputs).

- uses: jovanblazek/env-changes-detector@v2
  with:
    target-branch: ${{ github.event.pull_request.base.ref }}
    files: '["**.env-example", "**.env-test-example"]'

Inputs

Name Description Default Required
target-branch Target branch of PR. Set to PR target branch by default. github.event.pull_request.base.ref false
files Array of paths to check for changes. Can use glob patterns. See below for more examples. '["**.env-example", "**.env-test-example"]' false

Custom files

Customize paths to use when checking for changes using files input. You need to pass an array of strings as a string in order for it to work properly. Use parentheses " for array values and apostrophe ' to wrap the entire array.

files: '[".env-example", "api/.env-example"]'

You can also utilize glob patterns to search for files.

Outputs

Name Description If no changes detected
env-changes-detected Boolean value indicating if specified files have been changed. false
env-changes-raw Raw git diff output. ''
env-changes-md Generated report in Markdown. 'No env file changes detected.'

Do not forget to add id to your step to access the outputs.

Examples

Raw output:

diff --git a/.env.example b/.env.example
index b5fa0e7..f3cb836 100644
--- a/.env.example
+++ b/.env.example
@@ -1,1 +1,2 @@
-SECRET=
+HELLO_THERE=
+GENERAL_KENOBI=

Markdown output:

## Detected changes in env files:

#### `/.env.example`
```diff
-SECRET=
+HELLO_THERE=
+GENERAL_KENOBI=
```

Post comment when changes are detected

To post comment to PR when changes are detected, you need to utilize some other action. We recommend using this one: sticky-pull-request-comment

Example

- name: Detect changes in environment variables
  uses: jovanblazek/env-changes-detector@v2
  id: detect-changes-in-env-files

- name: Add or update sticky comment
  uses: marocchino/[email protected]
  with:
    message: |
      ${{ steps.detect-changes-in-env-files.outputs.env-changes-md }}

env-changes-detector's People

Contributors

jovanblazek avatar

Stargazers

LevelUpJoseph avatar  avatar

Forkers

cortlandd

env-changes-detector's Issues

Markdown output does not show that the file was moved

When the .env.example file is moved to a new location, the mardown output shows up like this:
image

File was moved from api to apps/node

Expected behavior:

  • show new file path in the output
  • if there are no changes in env file, the only change was that it was moved, the code block should say "File moved from <old path>"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.