Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09a879748c | ||
|
|
71afc9f3b8 | ||
|
|
bb5d1a8f64 | ||
|
|
23b35e63df | ||
|
|
12ed49be65 | ||
|
|
b54a7ae725 | ||
|
|
71583c0a06 | ||
|
|
e11c6b4fe2 | ||
|
|
d924fccc1e | ||
|
|
9e2f491e3f |
12
.github/workflows/test.yml
vendored
12
.github/workflows/test.yml
vendored
@@ -314,7 +314,7 @@ jobs:
|
||||
- name: Verify any_changed from source files
|
||||
if: |
|
||||
(
|
||||
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, 'action.yml') &&
|
||||
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, 'action.yml') &&
|
||||
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, '.github/workflows/test.yml') &&
|
||||
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, '.github/workflows/rebase.yml')
|
||||
)
|
||||
@@ -388,6 +388,16 @@ jobs:
|
||||
branch: ${{ steps.branch-name.outputs.base_ref_branch }}
|
||||
workflow_id: 'test.yml'
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run changed-files with since_last_remote_commit set to true
|
||||
id: changed-files-since-last-remote-commit
|
||||
uses: ./
|
||||
with:
|
||||
since_last_remote_commit: 'true'
|
||||
- name: Show output
|
||||
run: |
|
||||
echo '${{ toJSON(steps.changed-files-since-last-remote-commit.outputs) }}'
|
||||
shell:
|
||||
bash
|
||||
- name: Run changed-files with a custom base sha
|
||||
id: changed-files-custom-base-sha
|
||||
uses: ./
|
||||
|
||||
37
HISTORY.md
37
HISTORY.md
@@ -1,13 +1,34 @@
|
||||
# Changelog
|
||||
|
||||
## [Unreleased](https://github.com/tj-actions/changed-files/tree/HEAD)
|
||||
## [v11.4](https://github.com/tj-actions/changed-files/tree/v11.4) (2021-10-30)
|
||||
|
||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v11.2...HEAD)
|
||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v11.3...v11.4)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- \[Feature\] Get changed files in all commits in push [\#234](https://github.com/tj-actions/changed-files/issues/234)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Updated README.md [\#238](https://github.com/tj-actions/changed-files/pull/238) ([jackton1](https://github.com/jackton1))
|
||||
- Revert "Update base\_sha to use the last commit on the current branch for push event" [\#237](https://github.com/tj-actions/changed-files/pull/237) ([jackton1](https://github.com/jackton1))
|
||||
- Support retrieving changed files between the last remote commit and the current HEAD for push events [\#236](https://github.com/tj-actions/changed-files/pull/236) ([jackton1](https://github.com/jackton1))
|
||||
- Update base\_sha to use the last commit on the current branch for push event [\#235](https://github.com/tj-actions/changed-files/pull/235) ([jackton1](https://github.com/jackton1))
|
||||
- Upgraded to v11.3 [\#233](https://github.com/tj-actions/changed-files/pull/233) ([jackton1](https://github.com/jackton1))
|
||||
|
||||
## [v11.3](https://github.com/tj-actions/changed-files/tree/v11.3) (2021-10-27)
|
||||
|
||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v11.2...v11.3)
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- \[BUG\] Changed files not working on self hosted runners [\#227](https://github.com/tj-actions/changed-files/issues/227)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- \[Security\]: Prevent persisting the remote when there are errors [\#232](https://github.com/tj-actions/changed-files/pull/232) ([jackton1](https://github.com/jackton1))
|
||||
- Upgraded to v11.2 [\#231](https://github.com/tj-actions/changed-files/pull/231) ([jackton1](https://github.com/jackton1))
|
||||
|
||||
## [v11.2](https://github.com/tj-actions/changed-files/tree/v11.2) (2021-10-26)
|
||||
|
||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v11.1...v11.2)
|
||||
@@ -390,7 +411,7 @@
|
||||
|
||||
## [v7](https://github.com/tj-actions/changed-files/tree/v7) (2021-06-09)
|
||||
|
||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v6.3...v7)
|
||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v6...v7)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
@@ -406,13 +427,13 @@
|
||||
- Update tj-actions/sync-release-version action to v8.7 [\#86](https://github.com/tj-actions/changed-files/pull/86) ([renovate[bot]](https://github.com/apps/renovate))
|
||||
- Upgraded to v6.3 [\#85](https://github.com/tj-actions/changed-files/pull/85) ([jackton1](https://github.com/jackton1))
|
||||
|
||||
## [v6.3](https://github.com/tj-actions/changed-files/tree/v6.3) (2021-05-26)
|
||||
|
||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v6...v6.3)
|
||||
|
||||
## [v6](https://github.com/tj-actions/changed-files/tree/v6) (2021-05-26)
|
||||
|
||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v6.2...v6)
|
||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v6.3...v6)
|
||||
|
||||
## [v6.3](https://github.com/tj-actions/changed-files/tree/v6.3) (2021-05-26)
|
||||
|
||||
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v6.2...v6.3)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
|
||||
40
README.md
40
README.md
@@ -1,12 +1,12 @@
|
||||
[](https://github.com/tj-actions/changed-files/actions/workflows/test.yml) [](https://github.com/tj-actions/changed-files/actions/workflows/sync-release-version.yml) [](https://www.codacy.com/gh/tj-actions/changed-files/dashboard?utm\_source=github.com\&utm\_medium=referral\&utm\_content=tj-actions/changed-files\&utm\_campaign=Badge\_Grade) [](https://github.com/search?o=desc\&q=tj-actions+changed-files+language%3AYAML\&s=\&type=Code)
|
||||
[](https://github.com/tj-actions/changed-files/actions/workflows/test.yml) [](https://github.com/tj-actions/changed-files/actions/workflows/sync-release-version.yml) [](https://www.codacy.com/gh/tj-actions/changed-files/dashboard?utm_source=github.com\&utm_medium=referral\&utm_content=tj-actions/changed-files\&utm_campaign=Badge_Grade) [](https://github.com/search?o=desc\&q=tj-actions+changed-files+language%3AYAML\&s=\&type=Code)
|
||||
|
||||
[](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob\_idruns-on)
|
||||
[](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob\_idruns-on)
|
||||
[](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob\_idruns-on)
|
||||
[](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)
|
||||
[](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)
|
||||
[](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)
|
||||
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
||||
|
||||
[](#contributors-)
|
||||
[](#contributors-)
|
||||
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
||||
|
||||
@@ -59,7 +59,7 @@ jobs:
|
||||
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v11.2
|
||||
uses: tj-actions/changed-files@v11.4
|
||||
|
||||
- name: List all modified files
|
||||
run: |
|
||||
@@ -104,13 +104,14 @@ jobs:
|
||||
|
||||
| Input | type | required | default | description |
|
||||
|:-------------:|:-----------:|:-------------:|:-----------------------------:|:-------------:|
|
||||
| token | `string` | `false` | `${{ github.token }}` | [GITHUB\_TOKEN](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#using-the-github\_token-in-a-workflow) <br /> or a repo scoped <br /> [Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) |
|
||||
| token | `string` | `false` | `${{ github.token }}` | [GITHUB\_TOKEN](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow) <br /> or a repo scoped <br /> [Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) |
|
||||
| separator | `string` | `true` | `' '` | Output string separator |
|
||||
| files | `string` OR `string[]` | `false` | | Check for changes <br> using only these <br> list of file(s) <br> (Defaults to the <br> entire repo) |
|
||||
| base\_sha | `string` | `false` | | Specify a different <br> base commit SHA <br> used for <br> comparing changes |
|
||||
| sha | `string` | `true` | `${{ github.sha }}` | Specify a different <br> commit SHA <br> used for <br> comparing changes |
|
||||
| files\_from\_source\_file | `string` | `false` | | Source file <br> used to populate <br> the files input |
|
||||
| path | `string` | `false` | | Relative path under <br> `GITHUB_WORKSPACE` <br> to the repository |
|
||||
| since\_last\_remote\_commit | `string` | `false` | `false` | Use the last commit on the remote <br> branch as the `base_sha` for push event.<br> (Defaults to the previous commit). |
|
||||
|
||||
## Example
|
||||
|
||||
@@ -121,11 +122,11 @@ jobs:
|
||||
|
||||
- name: Get changed files using defaults
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v11.2
|
||||
uses: tj-actions/changed-files@v11.4
|
||||
|
||||
- name: Get changed files using a comma separator
|
||||
id: changed-files-comma
|
||||
uses: tj-actions/changed-files@v11.2
|
||||
uses: tj-actions/changed-files@v11.4
|
||||
with:
|
||||
separator: ","
|
||||
|
||||
@@ -147,7 +148,7 @@ jobs:
|
||||
|
||||
- name: Get specific changed files
|
||||
id: changed-files-specific
|
||||
uses: tj-actions/changed-files@v11.2
|
||||
uses: tj-actions/changed-files@v11.4
|
||||
with:
|
||||
files: |
|
||||
my-file.txt
|
||||
@@ -185,14 +186,14 @@ jobs:
|
||||
|
||||
- name: Use a source file or list of file(s) to populate to files input.
|
||||
id: changed-files-specific-source-file
|
||||
uses: tj-actions/changed-files@v11.2
|
||||
uses: tj-actions/changed-files@v11.4
|
||||
with:
|
||||
files_from_source_file: |
|
||||
test/changed-files-list.txt
|
||||
|
||||
- name: Use a source file or list of file(s) to populate to files input and optionally specify more files.
|
||||
id: changed-files-specific-source-file-and-specify-files
|
||||
uses: tj-actions/changed-files@v11.2
|
||||
uses: tj-actions/changed-files@v11.4
|
||||
with:
|
||||
files_from_source_file: |
|
||||
test/changed-files-list.txt
|
||||
@@ -201,13 +202,13 @@ jobs:
|
||||
|
||||
- name: Use a different commit SHA
|
||||
id: changed-files-custom-sha
|
||||
uses: tj-actions/changed-files@v11.2
|
||||
uses: tj-actions/changed-files@v11.4
|
||||
with:
|
||||
sha: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
- name: Use a different base SHA
|
||||
id: changed-files-custom-base-sha
|
||||
uses: tj-actions/changed-files@v11.2
|
||||
uses: tj-actions/changed-files@v11.4
|
||||
with:
|
||||
base_sha: "2096ed0"
|
||||
|
||||
@@ -219,7 +220,7 @@ jobs:
|
||||
|
||||
- name: Run changed-files with defaults on the dir1
|
||||
id: changed-files-for-dir1
|
||||
uses: tj-actions/changed-files@v11.2
|
||||
uses: tj-actions/changed-files@v11.4
|
||||
with:
|
||||
path: dir1
|
||||
|
||||
@@ -228,6 +229,13 @@ jobs:
|
||||
for file in ${{ steps.changed-files-for-dir1.outputs.added_files }}; do
|
||||
echo "$file was added"
|
||||
done
|
||||
|
||||
- name: Run changed-files with since_last_remote_commit set to true
|
||||
id: changed-files-since-last-remote-commit
|
||||
uses: tj-actions/changed-files@v11.4
|
||||
with:
|
||||
since_last_remote_commit: 'true'
|
||||
|
||||
```
|
||||
|
||||
### Running [pre-commit](https://pre-commit.com/) on all modified files
|
||||
@@ -241,7 +249,7 @@ jobs:
|
||||
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v11.2
|
||||
uses: tj-actions/changed-files@v11.4
|
||||
|
||||
- name: Pre-commit
|
||||
uses: pre-commit/action@v2.0.0
|
||||
|
||||
14
action.yml
14
action.yml
@@ -26,6 +26,10 @@ inputs:
|
||||
base_sha:
|
||||
description: 'Specify a base commit SHA on used for comparing changes'
|
||||
required: false
|
||||
since_last_remote_commit:
|
||||
description: 'Use the last commit on the remote branch as the base_sha for push event.'
|
||||
required: false
|
||||
default: 'false'
|
||||
path:
|
||||
description: 'Specify a relative path under $GITHUB_WORKSPACE to locate the repository'
|
||||
required: false
|
||||
@@ -90,6 +94,14 @@ runs:
|
||||
env:
|
||||
INPUT_FILES: ${{ inputs.files }}
|
||||
INPUT_FILES_FROM_SOURCE_FILE: ${{ inputs.files_from_source_file }}
|
||||
- run: |
|
||||
if [[ -n "${{ inputs.base_sha }}" ]]; then
|
||||
echo "::set-output name=base_sha::${{ inputs.base_sha }}"
|
||||
elif [[ "${{ inputs.since_last_remote_commit }}" == "true" && -z "${{ inputs.base_sha }}" ]]; then
|
||||
echo "::set-output name=base_sha::${{ github.event.before }}"
|
||||
fi
|
||||
id: base-sha
|
||||
shell: bash
|
||||
- run: |
|
||||
bash $GITHUB_ACTION_PATH/entrypoint.sh
|
||||
id: changed-files
|
||||
@@ -101,7 +113,7 @@ runs:
|
||||
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
|
||||
# https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611
|
||||
INPUT_SHA: ${{ inputs.sha }}
|
||||
INPUT_BASE_SHA: ${{ inputs.base_sha }}
|
||||
INPUT_BASE_SHA: ${{ steps.base-sha.outputs.base_sha }}
|
||||
INPUT_TOKEN: ${{ inputs.token }}
|
||||
INPUT_FILES: ${{ steps.source-input-files.outputs.files }}
|
||||
INPUT_SEPARATOR: ${{ inputs.separator }}
|
||||
|
||||
@@ -44,13 +44,14 @@ if [[ $exit_status -ne 0 ]]; then
|
||||
fi
|
||||
|
||||
if [[ -z $GITHUB_BASE_REF ]]; then
|
||||
TARGET_BRANCH=${GITHUB_REF/refs\/heads\//}
|
||||
CURRENT_BRANCH=$TARGET_BRANCH
|
||||
|
||||
if [[ -z $INPUT_BASE_SHA ]]; then
|
||||
PREVIOUS_SHA=$(git rev-parse HEAD^1 2>&1) && exit_status=$? || exit_status=$?
|
||||
else
|
||||
PREVIOUS_SHA=$INPUT_BASE_SHA
|
||||
PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$?
|
||||
fi
|
||||
TARGET_BRANCH=${GITHUB_REF/refs\/heads\//}
|
||||
CURRENT_BRANCH=$TARGET_BRANCH
|
||||
|
||||
if [[ $exit_status -ne 0 ]]; then
|
||||
echo "::warning::Unable to determine the previous commit sha"
|
||||
|
||||
Reference in New Issue
Block a user