Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8ace0110c | ||
|
|
e83c52fc11 | ||
|
|
853caa603d | ||
|
|
17e2510d74 | ||
|
|
e858c485a2 | ||
|
|
19483649c5 | ||
|
|
c061ef1fa3 | ||
|
|
84fd7c7a42 | ||
|
|
af5a2e5d10 | ||
|
|
e8f8d088f6 | ||
|
|
c23398e584 | ||
|
|
9352b30cc3 | ||
|
|
7b1f7ad57b | ||
|
|
e368753cac | ||
|
|
b47ed0ffe6 | ||
|
|
0e1d04f780 | ||
|
|
814a7ea227 | ||
|
|
4420c3c441 | ||
|
|
feadcbc861 | ||
|
|
b60f5e56b6 |
5
.github/workflows/test.yml
vendored
5
.github/workflows/test.yml
vendored
@@ -1,6 +1,9 @@
|
|||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
@@ -12,6 +15,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
- name: Run changed-files with defaults
|
- name: Run changed-files with defaults
|
||||||
id: changed-files
|
id: changed-files
|
||||||
uses: ./
|
uses: ./
|
||||||
|
|||||||
41
CHANGELOG.md
41
CHANGELOG.md
@@ -1,41 +0,0 @@
|
|||||||
# Changelog
|
|
||||||
|
|
||||||
## [v3](https://github.com/tj-actions/changed-files/tree/v3) (2021-04-02)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v2.1...v3)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Update action.yml [\#11](https://github.com/tj-actions/changed-files/pull/11) ([jackton1](https://github.com/jackton1))
|
|
||||||
- Update README.md [\#10](https://github.com/tj-actions/changed-files/pull/10) ([jackton1](https://github.com/jackton1))
|
|
||||||
- Configure Renovate [\#9](https://github.com/tj-actions/changed-files/pull/9) ([renovate[bot]](https://github.com/apps/renovate))
|
|
||||||
- Update test.yml [\#8](https://github.com/tj-actions/changed-files/pull/8) ([jackton1](https://github.com/jackton1))
|
|
||||||
- Upgraded to v2.1 [\#6](https://github.com/tj-actions/changed-files/pull/6) ([jackton1](https://github.com/jackton1))
|
|
||||||
|
|
||||||
## [v2.1](https://github.com/tj-actions/changed-files/tree/v2.1) (2021-03-18)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v2...v2.1)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Upgraded to v2 [\#5](https://github.com/tj-actions/changed-files/pull/5) ([jackton1](https://github.com/jackton1))
|
|
||||||
|
|
||||||
## [v2](https://github.com/tj-actions/changed-files/tree/v2) (2021-03-14)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v1...v2)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Fixed end of string with separator [\#4](https://github.com/tj-actions/changed-files/pull/4) ([jackton1](https://github.com/jackton1))
|
|
||||||
|
|
||||||
## [v1](https://github.com/tj-actions/changed-files/tree/v1) (2021-03-05)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/7eba13b12c69e63845b6d8bf1d3453edb0549ff9...v1)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Update action.yml [\#2](https://github.com/tj-actions/changed-files/pull/2) ([jackton1](https://github.com/jackton1))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
|
||||||
22
HISTORY.md
22
HISTORY.md
@@ -1,5 +1,27 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [v4](https://github.com/tj-actions/changed-files/tree/v4) (2021-04-23)
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v3.3...v4)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- Feature request [\#15](https://github.com/tj-actions/changed-files/issues/15)
|
||||||
|
- Added support for push events [\#21](https://github.com/tj-actions/changed-files/pull/21) ([jackton1](https://github.com/jackton1))
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Upgraded to v3.3 [\#19](https://github.com/tj-actions/changed-files/pull/19) ([jackton1](https://github.com/jackton1))
|
||||||
|
|
||||||
|
## [v3.3](https://github.com/tj-actions/changed-files/tree/v3.3) (2021-04-20)
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v3.2...v3.3)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Update action.yml [\#18](https://github.com/tj-actions/changed-files/pull/18) ([jackton1](https://github.com/jackton1))
|
||||||
|
- Upgraded to v3.2 [\#17](https://github.com/tj-actions/changed-files/pull/17) ([jackton1](https://github.com/jackton1))
|
||||||
|
|
||||||
## [v3.2](https://github.com/tj-actions/changed-files/tree/v3.2) (2021-04-11)
|
## [v3.2](https://github.com/tj-actions/changed-files/tree/v3.2) (2021-04-11)
|
||||||
|
|
||||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v3.1...v3.2)
|
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v3.1...v3.2)
|
||||||
|
|||||||
58
README.md
58
README.md
@@ -3,18 +3,36 @@
|
|||||||
changed-files
|
changed-files
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
Get modified files using [`git diff --diff-filter`](https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203) to locate all files that have been modified relative to the default branch.
|
Get all modified files relative to the default branch or preceding commit.
|
||||||
|
|
||||||
> NOTE: :warning: This action should only run on the following events :warning:
|
|
||||||
> * [pull_request](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request)
|
|
||||||
> * [pull_request_review](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_review)
|
|
||||||
> * [pull_request_review_comment](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_review_comment)
|
|
||||||
> * [pull_request_target](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target)
|
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
With defaults
|
### Push event
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test changed-files
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
|
||||||
|
- name: Get changed files
|
||||||
|
id: changed_files
|
||||||
|
uses: tj-actions/changed-files@v4
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Pull Request events
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: CI
|
name: CI
|
||||||
@@ -31,8 +49,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Get changed files
|
- name: Get changed files
|
||||||
id: changed-files
|
id: changed_files
|
||||||
uses: tj-actions/changed-files@v3.2
|
uses: tj-actions/changed-files@v4
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -43,28 +61,28 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Get changed files using defaults
|
- name: Get changed files using defaults
|
||||||
id: changed-files
|
id: changed_files
|
||||||
uses: tj-actions/changed-files@v3.2
|
uses: tj-actions/changed-files@v4
|
||||||
|
|
||||||
- name: Get changed files using a comma separator
|
- name: Get changed files using a comma separator
|
||||||
id: changed-files-comma
|
id: changed_files_comma
|
||||||
uses: tj-actions/changed-files@v3.2
|
uses: tj-actions/changed-files@v4
|
||||||
with:
|
with:
|
||||||
separator: ","
|
separator: ","
|
||||||
|
|
||||||
- name: List all added files
|
- name: List all added files
|
||||||
run: |
|
run: |
|
||||||
for file in "${{ steps.changed-files.outputs.added_files }}"; do
|
for file in "${{ steps.changed_files.outputs.added_files }}"; do
|
||||||
echo $file
|
echo $file
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Run step when a file changes in a PR relative to the default branch
|
- name: Run step when a file changes in a PR relative to the default branch
|
||||||
if: contains(steps.changed-files.outputs.modified_files, 'my-file.txt')
|
if: contains(steps.changed_files.outputs.modified_files, 'my-file.txt')
|
||||||
run: |
|
run: |
|
||||||
echo "Your file my-file.txt has been modified."
|
echo "Your file my-file.txt has been modified."
|
||||||
|
|
||||||
- name: Run step when a file is deleted in a PR relative to the default branch
|
- name: Run step when a file is deleted in a PR relative to the default branch
|
||||||
if: contains(steps.changed-files.outputs.deleted_files, 'test.txt')
|
if: contains(steps.changed_files.outputs.deleted_files, 'test.txt')
|
||||||
run: |
|
run: |
|
||||||
echo "Your test.txt has been deleted."
|
echo "Your test.txt has been deleted."
|
||||||
|
|
||||||
@@ -81,13 +99,13 @@ jobs:
|
|||||||
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
|
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
|
||||||
|
|
||||||
- name: Get changed files
|
- name: Get changed files
|
||||||
id: changed-files
|
id: changed_files
|
||||||
uses: tj-actions/changed-files@v3.2
|
uses: tj-actions/changed-files@v4
|
||||||
|
|
||||||
- name: Pre-commit
|
- name: Pre-commit
|
||||||
uses: pre-commit/action@v2.0.0
|
uses: pre-commit/action@v2.0.0
|
||||||
with:
|
with:
|
||||||
extra_args: -v --hook-stage push --files ${{ steps.changed-files.outputs.all_modified_files }}
|
extra_args: -v --hook-stage push --files ${{ steps.changed_files.outputs.all_modified_files }}
|
||||||
token: ${{ secrets.github_token }}
|
token: ${{ secrets.github_token }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
44
action.yml
44
action.yml
@@ -10,53 +10,51 @@ inputs:
|
|||||||
outputs:
|
outputs:
|
||||||
added_files:
|
added_files:
|
||||||
description: List of added files.
|
description: List of added files.
|
||||||
value: ${{ steps.changed-files.outputs.added_files }}
|
value: ${{ steps.changed_files.outputs.added_files }}
|
||||||
copied_files:
|
copied_files:
|
||||||
description: List of copied files.
|
description: List of copied files.
|
||||||
value: ${{ steps.changed-files.outputs.copied_files }}
|
value: ${{ steps.changed_files.outputs.copied_files }}
|
||||||
deleted_files:
|
deleted_files:
|
||||||
description: List of deleted files.
|
description: List of deleted files.
|
||||||
value: ${{ steps.changed-files.outputs.deleted_files }}
|
value: ${{ steps.changed_files.outputs.deleted_files }}
|
||||||
modified_files:
|
modified_files:
|
||||||
description: List of modified files.
|
description: List of modified files.
|
||||||
value: ${{ steps.changed-files.outputs.modified_files }}
|
value: ${{ steps.changed_files.outputs.modified_files }}
|
||||||
renamed_files:
|
renamed_files:
|
||||||
description: List of renamed files.
|
description: List of renamed files.
|
||||||
value: ${{ steps.changed-files.outputs.renamed_files }}
|
value: ${{ steps.changed_files.outputs.renamed_files }}
|
||||||
changed_files:
|
changed_files:
|
||||||
description: List of changed files.
|
description: List of changed files.
|
||||||
value: ${{ steps.changed-files.outputs.changed_files }}
|
value: ${{ steps.changed_files.outputs.changed_files }}
|
||||||
unmerged_files:
|
unmerged_files:
|
||||||
description: List of unmerged files.
|
description: List of unmerged files.
|
||||||
value: ${{ steps.changed-files.outputs.unmerged_files }}
|
value: ${{ steps.changed_files.outputs.unmerged_files }}
|
||||||
unknown_files:
|
unknown_files:
|
||||||
description: List of unknown files.
|
description: List of unknown files.
|
||||||
value: ${{ steps.changed-files.outputs.unknown_files }}
|
value: ${{ steps.changed_files.outputs.unknown_files }}
|
||||||
all_changed_files:
|
all_changed_files:
|
||||||
description: List of all changed files.
|
description: List of all changed files.
|
||||||
value: ${{ steps.changed-files.outputs.all_changed_files }}
|
value: ${{ steps.changed_files.outputs.all_changed_files }}
|
||||||
all_modified_files:
|
all_modified_files:
|
||||||
description: List of all copied modified and added files
|
description: List of all copied modified and added files
|
||||||
value: ${{ steps.changed-files.outputs.all_modified_files }}
|
value: ${{ steps.changed_files.outputs.all_modified_files }}
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
steps:
|
steps:
|
||||||
- id: changed-files
|
- id: changed_files
|
||||||
run: |
|
run: |
|
||||||
|
echo "Getting head sha..."
|
||||||
|
|
||||||
if [[ -z $GITHUB_BASE_REF ]]; then
|
if [[ -z $GITHUB_BASE_REF ]]; then
|
||||||
echo "Skipping: This should only run on pull_request.";
|
HEAD_SHA=$(git rev-parse HEAD^1 || true)
|
||||||
exit 0;
|
else
|
||||||
|
TARGET_BRANCH=${GITHUB_BASE_REF}
|
||||||
|
git fetch --depth=1 origin ${TARGET_BRANCH}:${TARGET_BRANCH}
|
||||||
|
HEAD_SHA=$(git rev-parse ${TARGET_BRANCH} || true)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TARGET_BRANCH=${GITHUB_BASE_REF}
|
echo "Getting diff..."
|
||||||
|
|
||||||
git fetch --depth=1 origin ${TARGET_BRANCH}:${TARGET_BRANCH}
|
|
||||||
|
|
||||||
echo "Getting head sha..."
|
|
||||||
|
|
||||||
HEAD_SHA=$(git rev-parse ${TARGET_BRANCH} || true)
|
|
||||||
|
|
||||||
ADDED=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
ADDED=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
||||||
COPIED=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
COPIED=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
||||||
DELETED=$(git diff --diff-filter=D --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
DELETED=$(git diff --diff-filter=D --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
||||||
@@ -68,7 +66,7 @@ runs:
|
|||||||
ALL_CHANGED=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
ALL_CHANGED=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
||||||
ALL_MODIFIED_FILES=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
ALL_MODIFIED_FILES=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
||||||
|
|
||||||
echo "Getting diff..."
|
|
||||||
echo "::set-output name=added_files::$ADDED"
|
echo "::set-output name=added_files::$ADDED"
|
||||||
echo "::set-output name=copied_files::$COPIED"
|
echo "::set-output name=copied_files::$COPIED"
|
||||||
echo "::set-output name=deleted_files::$DELETED"
|
echo "::set-output name=deleted_files::$DELETED"
|
||||||
@@ -82,5 +80,5 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
icon: git-pull-request
|
icon: list
|
||||||
color: white
|
color: white
|
||||||
|
|||||||
Reference in New Issue
Block a user