Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to prepend the workspace path to the list of files #40

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
54f3703
Remove response.data.status check
sargunv Mar 15, 2021
900e9d7
build
sargunv Mar 15, 2021
1beff32
Support pull_request_target
Ana06 May 19, 2021
c55c408
Update node to a newer version
Ana06 May 26, 2021
494461c
Rename master branch => main
Ana06 May 26, 2021
4a8eff5
Add filter regex
rmed19 Apr 30, 2021
5e2c31d
Fix filter in action.yml
Ana06 May 26, 2021
45d873a
Prepare release of v1.1
Ana06 May 26, 2021
f51efe5
Remove response.data.status check
sargunv Mar 15, 2021
a2f6df8
Prepare release of v1.2
Ana06 Jun 4, 2021
48961ca
Merge pull request #2 from rnsc/main
rnsc Jun 28, 2021
42676e4
Replace glob-filter by filter in test workflow
Ana06 Jul 27, 2021
32ee6f5
chore(deps): bump glob-parent from 5.1.1 to 5.1.2
dependabot[bot] Jul 27, 2021
b235444
chore(deps): bump y18n from 4.0.0 to 4.0.3
dependabot[bot] Jul 27, 2021
bd65f20
chore(deps): bump lodash from 4.17.15 to 4.17.21
dependabot[bot] Jul 27, 2021
8c28730
Merge pull request #3 from Ana06/dependabot/npm_and_yarn/glob-parent-…
Ana06 Jul 27, 2021
1e065fa
Merge pull request #4 from Ana06/dependabot/npm_and_yarn/y18n-4.0.3
Ana06 Jul 27, 2021
98e4db7
chore(deps): bump hosted-git-info from 2.8.8 to 2.8.9
dependabot[bot] Jul 27, 2021
cb55a10
chore(deps): bump ws from 7.2.3 to 7.5.3
dependabot[bot] Jul 27, 2021
0b68882
Merge pull request #5 from Ana06/dependabot/npm_and_yarn/lodash-4.17.21
Ana06 Jul 27, 2021
2b8f3ea
Merge pull request #7 from Ana06/dependabot/npm_and_yarn/hosted-git-i…
Ana06 Jul 27, 2021
7893294
Merge pull request #6 from Ana06/dependabot/npm_and_yarn/ws-7.5.3
Ana06 Jul 27, 2021
ea75ed7
Small improvements in test workflow
Ana06 Jul 27, 2021
40a8521
Add option to prepend the workspace path to the list of files
jaredly Aug 4, 2021
b4d0970
redist
jaredly Aug 4, 2021
74f928e
Merge branch 'patch-1' of https://github.com/sargunv/get-changed-file…
jaredly Aug 4, 2021
e78d018
fix
jaredly Aug 4, 2021
f758fa4
merge https://github.com/Ana06/get-changed-files/releases/tag/v1.2
jaredly Aug 4, 2021
696e6f7
try using the base /ref/
jaredly Aug 4, 2021
89d3dca
oh rebuild for real
jaredly Aug 4, 2021
e43e53e
1.0.1
jaredly Aug 4, 2021
43f54d4
merge
jaredly Aug 4, 2021
8b82882
revert
jaredly Aug 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
push:
branches:
- master
- main
- releases/*

jobs:
Expand Down Expand Up @@ -55,10 +55,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: '12'

- name: Install dependencies
run: |
yarn
Expand Down Expand Up @@ -87,14 +83,34 @@ jobs:
uses: actions/checkout@v2

- id: files
name: Run the action
uses: ./
name: Run the action without filtering

- name: Print steps context output
- name: Print files
run: |
echo 'steps.files.outputs.all=${{ steps.files.outputs.all }}'
echo 'steps.files.outputs.added=${{ steps.files.outputs.added }}'
echo 'steps.files.outputs.modified=${{ steps.files.outputs.modified }}'
echo 'steps.files.outputs.removed=${{ steps.files.outputs.removed }}'
echo 'steps.files.outputs.renamed=${{ steps.files.outputs.renamed }}'
echo 'steps.files.outputs.added_modified=${{ steps.files.outputs.added_modified }}'

- id: files-filtered
name: Run the action with filtering
with:
filter: |
*.yml
!.github/*/*.yml
*.js
*.ts
package*
!*.json

- name: Print files-filtered
run: |
echo 'steps.files-filtered.outputs.all=${{ steps.files-filtered.outputs.all }}'
echo 'steps.files-filtered.outputs.added=${{ steps.files-filtered.outputs.added }}'
echo 'steps.files-filtered.outputs.modified=${{ steps.files-filtered.outputs.modified }}'
echo 'steps.files-filtered.outputs.removed=${{ steps.files-filtered.outputs.removed }}'
echo 'steps.files-filtered.outputs.renamed=${{ steps.files-filtered.outputs.renamed }}'
echo 'steps.files-filtered.outputs.added_modified=${{ steps.files-filtered.outputs.added_modified }}'

87 changes: 66 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,84 +1,129 @@
<p align="center">
<a href="https://github.com/jitterbit/get-changed-files/actions"><img alt="jitterbit/get-changed-files status" src="https://github.com/jitterbit/get-changed-files/workflows/Test/badge.svg"></a>
</p>
# get-changed-files

# Get All Changed Files
[![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)

Get all of the files changed/modified in a pull request or push's commits.
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.
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
## Usage

See [action.yml](action.yml)

```yaml
- uses: jitterbit/get-changed-files@v1
- uses: Ana06/get-changed-files@v2.0.0
with:
# Format of the steps output context.
# Can be 'space-delimited', 'csv', or 'json'.
# Default: 'space-delimited'
format: ''
# Filter files using a glob filter
filter: '*'
```

# Scenarios
## Scenarios

- [Get all changed files as space-delimited](#get-all-changed-files-as-space-delimited)
- [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)
- [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)

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

```yaml
- id: files
uses: jitterbit/get-changed-files@v1
uses: Ana06/get-changed-files@v2.0.0
- 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
### 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
with:
filter: '*.php'
- run: |
for changed_file in ${{ steps.files.outputs.all }}; do
echo "Do something with this ${changed_file}."
done
```

### 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
with:
filter: |
*.yml
!.github/*/*.yml
```

### Get all added and modified files as CSV

```yaml
- id: files
uses: jitterbit/get-changed-files@v1
uses: Ana06/get-changed-files@v2.0.0
with:
format: 'csv'
filter: '*'
- 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
```

## Get all removed files as JSON
### Get all removed files as JSON

```yaml
- id: files
uses: jitterbit/get-changed-files@v1
uses: Ana06/get-changed-files@v2.0.0
with:
format: 'json'
filter: '*'
- 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
## Install, Build, Lint, Test, and Package

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

```bash
$ yarn
$ yarn all
yarn
yarn all
```

# License
## License

The scripts and documentation in this project are released under the [MIT License](LICENSE)
12 changes: 10 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Get All Changed Files
description: Get all of the files changed/modified in a pull request or push's commits.
name: Get Changed Files
description: Get all files changed/modified in a pull request or push's commits. This project is a fork of https://github.com/jitterbit/get-changedfiles, which supports pull_request_target and allow to filter files using regular expressions
author: Jitterbit, Inc.
branding:
icon: file
Expand All @@ -20,6 +20,14 @@ inputs:
Can be 'space-delimited', 'csv', or 'json'.
required: true
default: space-delimited
absolute:
description: >
Prepend the workspace root to the file paths.
Useful if you're checking them out.
required: false
filter:
required: true
default: '*'
outputs:
all:
description: >
Expand Down
Loading