Skip to content

Commit

Permalink
Prepare v2.1.0 & improve readme
Browse files Browse the repository at this point in the history
Improve documentation and prepare for v2.1.0 release.

- Renamed files that are also modified are included in `renamed`, `modified` and `added_modified`.
  • Loading branch information
Ana06 committed Dec 21, 2021
1 parent 47aa8c6 commit a6591c9
Showing 1 changed file with 30 additions and 25 deletions.
55 changes: 30 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,31 @@
[![CI status](https://github.com/Ana06/get-changed-files/workflows/Test/badge.svg)](https://github.com/Ana06/get-changed-files/actions?query=event%3Apush+branch%3Amain)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE.txt)

This project is a fork of <https://github.com/jitterbit/get-changed-files>, which supports `pull_request_target`, allow to filter files using regular expressions and removes the ahead check.

## Get All Changed Files

Get all of the files changed/modified in a pull request (`pull_request` or `pull_request_target`) or push's commits.
Get all changed/modified files in a pull request (`pull_request` or `pull_request_target`) 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`.
Renamed files that are also modified are included in `renamed`, `modified` and `added_modified`.

This project is a fork of <https://github.com/jitterbit/get-changed-files>, which supports `pull_request_target`, allow to filter files using regular expressions, removes the ahead check and considers renamed modified files as modified.

- [Usage](#usage)
- [Filtering](#filtering)
- [Examples](#examples)
- [Get all changed files as space-delimited](#get-all-changed-files-as-space-delimited)
- [Get all changed `*.php` files as space-delimited](#get-all-changed-php-files-as-space-delimited)
- [Get all changed `*.yml` files but exclude `.github/*/*.yml` files](#get-all-changed-yml-files-but-exclude-githubyml-files)
- [Get all added and modified files as CSV](#get-all-added-and-modified-files-as-csv)
- [Get all removed files as JSON](#get-all-removed-files-as-json)
- [Install, Build, Lint, Test, and Package](#install-build-lint-test-and-package)
- [License](#license)

## Usage

See [action.yml](action.yml)

```yaml
- uses: Ana06/get-changed-files@v2.0.0
- uses: Ana06/get-changed-files@v2.1.0
with:
# Format of the steps output context.
# Can be 'space-delimited', 'csv', or 'json'.
Expand All @@ -27,19 +37,14 @@ See [action.yml](action.yml)
filter: '*'
```
## Scenarios
### Filtering
You can filter files using regular expressions with the `filter` option.
This option receives a list of patterns using [GitHub Actions syntax](https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet).
You can use `!` at the start of a pattern to negate previous positive patterns.
See the [Get all changed `*.yml` files but exclude `.github/*/*.yml` files](#get-all-changed-yml-files-but-exclude-githubyml-files) example.

- [get-changed-files](#get-changed-files)
- [Get All Changed Files](#get-all-changed-files)
- [Usage](#usage)
- [Scenarios](#scenarios)
- [Get all changed files as space-delimited](#get-all-changed-files-as-space-delimited)
- [Get all changed *.php files as space-delimited](#get-all-changed-php-files-as-space-delimited)
- [Get all changed *.yml files but exclude .github/*/*.yml files](#get-all-changed-yml-files-but-exclude-githubyml-files)
- [Get all added and modified files as CSV](#get-all-added-and-modified-files-as-csv)
- [Get all removed files as JSON](#get-all-removed-files-as-json)
- [Install, Build, Lint, Test, and Package](#install-build-lint-test-and-package)
- [License](#license)
## Examples

### Get all changed files as space-delimited

Expand All @@ -48,21 +53,21 @@ Consider using one of the other formats if that's the case.

```yaml
- id: files
uses: Ana06/get-changed-files@v2.0.0
uses: Ana06/get-changed-files@v2.1.0
- run: |
for changed_file in ${{ steps.files.outputs.all }}; do
echo "Do something with this ${changed_file}."
done
```

### Get all changed *.php files as space-delimited
### Get all changed `*.php` 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.

```yaml
- id: files
uses: Ana06/get-changed-files@v2.0.0
uses: Ana06/get-changed-files@v2.1.0
with:
filter: '*.php'
- run: |
Expand All @@ -71,14 +76,14 @@ Consider using one of the other formats if that's the case.
done
```

### Get all changed *.yml files but exclude .github/*/*.yml files
### Get all changed `*.yml` files but exclude `.github/*/*.yml` files

Be careful that the order of the glob has an importance.
Therefore, including all YML files first and excluding the YML files of your `.github/*/` directories is the way to go to exclude them.
If those two globs were inverted, you **would** include all the YML files, with the ones in your `.github/*/` directories.

```yaml
- uses: Ana06/get-changed-files@v2.0.0
- uses: Ana06/get-changed-files@v2.1.0
with:
filter: |
*.yml
Expand All @@ -89,7 +94,7 @@ If those two globs were inverted, you **would** include all the YML files, with

```yaml
- id: files
uses: Ana06/get-changed-files@v2.0.0
uses: Ana06/get-changed-files@v2.1.0
with:
format: 'csv'
filter: '*'
Expand All @@ -104,7 +109,7 @@ If those two globs were inverted, you **would** include all the YML files, with

```yaml
- id: files
uses: Ana06/get-changed-files@v2.0.0
uses: Ana06/get-changed-files@v2.1.0
with:
format: 'json'
filter: '*'
Expand Down

0 comments on commit a6591c9

Please sign in to comment.