Giter VIP home page Giter VIP logo

get-changed-files's Introduction

jitterbit/get-changed-files status

Get All Changed Files

Get all of the files changed/modified in a pull request or push's commits. You can choose to get all changed files, only added files, only modified files, only removed files, only renamed files, or all added and modified files. These outputs are available via the steps output context. The steps output context exposes the output names all, added, modified, removed, renamed, and added_modified.

Usage

See action.yml

- uses: jitterbit/get-changed-files@v1
  with:
    # Format of the steps output context.
    # Can be 'space-delimited', 'csv', or 'json'.
    # Default: 'space-delimited'
    format: ''

Scenarios

Get all changed files as space-delimited

If there are any files with spaces in them, then this method won't work and the step will fail. Consider using one of the other formats if that's the case.

- id: files
  uses: jitterbit/get-changed-files@v1
- run: |
    for changed_file in ${{ steps.files.outputs.all }}; do
      echo "Do something with this ${changed_file}."
    done

Get all added and modified files as CSV or SQL

- id: files
  uses: jitterbit/get-changed-files@v1
  with:
    format: 'csv'
- run: |
    mapfile -d ',' -t added_modified_files < <(printf '%s,' '${{ steps.files.outputs.added_modified }}')
    for added_modified_file in "${added_modified_files[@]}"; do
      echo "Do something with this ${added_modified_file}."
    done
- id: changed-files
  uses: gulivan/get-changed-files@v1
  with:
    format: 'sql'
- name: execute changed files # bash script. Sometimes, not sql files are being parsed, so the if statement was added to handle it
  run: |
    mapfile -d ',' -t added_modified_files < <(printf '%s,' '${{ steps.changed-files.outputs.added_modified }}')
    for added_modified_file in "${added_modified_files[@]}"; do
      if [[ ${added_modified_file} == *.sql ]]; then
        echo sql detected, executing: ~/snowflake/snowsql -f ${added_modified_file}.
        ~/snowflake/snowsql -f ${added_modified_file}
      fi
    done

Get all removed files as JSON

- id: files
  uses: jitterbit/get-changed-files@v1
  with:
    format: 'json'
- run: |
    readarray -t removed_files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.removed }}')"
    for removed_file in ${removed_files[@]}; do
      echo "Do something with this ${removed_file}."
    done

Install, Build, Lint, Test, and Package

Make sure to do the following before checking in any code changes.

$ yarn
$ yarn all

License

The scripts and documentation in this project are released under the MIT License

get-changed-files's People

Contributors

dependabot[bot] avatar gulivan avatar sean-krail avatar

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.