Compare commits

...

34 Commits

Author SHA1 Message Date
Tonye Jack
30988915fa Update entrypoint.sh 2021-12-04 07:50:37 -05:00
Tonye Jack
f4ece4ed57 Resolve error adding remote (#269)
Fixes: #268
2021-12-04 07:49:00 -05:00
Tonye Jack
b1b88f09a2 Resolve error setting the base sha (#272)
* Resolve error setting the base sha

* Update action.yml

* Update action.yml
2021-12-04 07:31:37 -05:00
Tonye Jack
66714ebcad Fixed error with test (#270)
* Fixed error with test

* Update action.yml
2021-12-04 07:00:44 -05:00
Tonye Jack
3ef3d14e6d Improve error handling (#263)
* Improve error handling

Fixes: #255

* Update entrypoint.sh

* Update entrypoint.sh

* Update error checking

* Update test.yml

* Update test.yml

* Update test.yml

* Update entrypoint.sh

* Update action.yml

* Update entrypoint.sh

* Update entrypoint.sh

* Update entrypoint.sh

* Update test.yml

* Update entrypoint.sh

* Update test.yml

* Update test.yml

* Update test.yml

* Update entrypoint.sh

* Update entrypoint.sh

* Update entrypoint.sh

* Update test.yml
2021-12-04 06:11:27 -05:00
Tonye Jack
0a8c804187 Update base sha step to use output grouping (#266)
* Update base sha step to use output grouping

* Update action.yml

* Update action.yml

* Update action.yml
2021-11-30 12:12:51 -05:00
Tonye Jack
fb46697b26 Update README.md (#262) 2021-11-29 16:02:29 -05:00
Tonye Jack
243b81766a Updated README.md (#260)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-11-24 15:25:57 -05:00
Tonye Jack
e71d15e5da Update README.md 2021-11-24 14:54:01 -05:00
Tonye Jack
a3d0fc798e Update README.md 2021-11-24 14:51:55 -05:00
Tonye Jack
cb2ab79827 Update README.md 2021-11-24 14:04:39 -05:00
Tonye Jack
5515da09bf Update README.md 2021-11-19 23:59:21 -05:00
Tonye Jack
1622678cd7 Update README.md 2021-11-19 17:15:35 -05:00
Tonye Jack
400b2ce7f5 Updated README.md (#258)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-11-19 17:07:26 -05:00
Tonye Jack
9046b77400 Update README.md 2021-11-19 17:00:55 -05:00
Tonye Jack
98695e35af Update README.md 2021-11-19 16:56:40 -05:00
Tonye Jack
248a1050a8 Upgraded from v1.2.2 -> v11.7 (#257)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-11-19 16:53:00 -05:00
Tonye Jack
8dfe0ee3f4 Upgraded from v11.6 -> v1.2.2 (#256)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-11-19 16:36:07 -05:00
Tonye Jack
467d26c8b7 Updated git fetch to pull the last remote commit (#254)
* Update entrypoint.sh

* Update entrypoint.sh

* Update entrypoint.sh

* Update entrypoint.sh

* Update entrypoint.sh

* Update entrypoint.sh
2021-11-19 16:27:56 -05:00
Tonye Jack
bb40edd264 Update README.md 2021-11-18 19:09:51 -05:00
Tonye Jack
c6de787438 Updated .github/workflows/auto-merge.yml 2021-11-16 16:27:36 -05:00
Renovate Bot
45f1e8fb92 Update reviewdog/action-shellcheck action to v1.12 2021-11-16 11:01:29 -05:00
Renovate Bot
ff85b03c27 Update reviewdog/action-shellcheck action to v1.11 2021-11-13 05:10:59 -05:00
Tonye Jack
bc42b5f993 Upgraded from v1.2.1 -> v11.6 (#249)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-11-08 09:35:03 -05:00
Tonye Jack
aae164d51b Upgraded from v1.2.0 -> v1.2.1 (#248)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-11-08 08:35:22 -05:00
Tonye Jack
d9eb683b30 Updated formatting of all modified debug message (#247)
* Updated formatting of all modified debug message

* Update entrypoint.sh

* Update changed-files-list.txt

* Update changed-files-list.txt
2021-11-08 08:17:51 -05:00
Renovate Bot
3f78450f6c Update reviewdog/action-shellcheck action to v1.10 2021-11-07 10:37:02 -05:00
Tonye Jack
b84b6ca11b Update README.md 2021-11-04 01:55:44 -04:00
Renovate Bot
fa48a435b3 Update peter-evans/create-pull-request action to v3.11.0 2021-11-03 23:05:00 -04:00
Renovate Bot
2a91a6204f Update actions/checkout action to v2.4.0 2021-11-02 15:47:19 -04:00
Tonye Jack
a6d5b37cba Removed unused check 2021-11-02 07:43:24 -04:00
Tonye Jack
3ebf0a6369 Update README.md 2021-10-30 20:13:18 -04:00
Tonye Jack
ddc5ed8372 Update README.md 2021-10-30 16:23:17 -04:00
Tonye Jack
8bf07a8b5d Upgraded from v11.4 -> v11.5 (#241)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-10-30 16:19:47 -04:00
10 changed files with 198 additions and 59 deletions

View File

@@ -2,7 +2,6 @@ name: automerge
on:
check_suite:
types:
- rerequested
- completed
jobs:
@@ -19,9 +18,9 @@ jobs:
- name: automerge
uses: pascalgn/automerge-action@v0.14.3
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN || github.token }}
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
MERGE_METHOD: "rebase"
UPDATE_METHOD: "rebase"
MERGE_RETRIES: "6"
MERGE_RETRY_SLEEP: "100000"
MERGE_LABELS: ""
MERGE_LABELS: ""

View File

@@ -8,7 +8,7 @@ jobs:
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v2.4.0
with:
token: ${{ secrets.PAT_TOKEN }}
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

View File

@@ -8,7 +8,7 @@ jobs:
update-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v2.4.0
with:
fetch-depth: 0
- name: Sync release version.
@@ -23,7 +23,7 @@ jobs:
with:
output: 'HISTORY.md'
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3.10.1
uses: peter-evans/create-pull-request@v3.11.0
with:
base: "main"
title: "Upgraded to ${{ steps.sync-release-version.outputs.new_version }}"

View File

@@ -18,7 +18,7 @@ jobs:
- name: Checkout to branch
uses: actions/checkout@v2
- name: shellcheck
uses: reviewdog/action-shellcheck@v1.9
uses: reviewdog/action-shellcheck@v1.12
test-multiple-repositories:
name: Test with multiple repositories
@@ -73,8 +73,8 @@ jobs:
shell:
bash
test-no-head-sha:
name: Test changed-files missing head sha
test-non-existent-base-sha:
name: Test changed-files non existent base sha
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
@@ -85,16 +85,71 @@ jobs:
- name: Checkout to branch
uses: actions/checkout@v2
- name: Run changed-files with defaults
- name: Run changed-files with non existent base sha
id: changed-files
continue-on-error: true
uses: ./
continue-on-error: true
with:
base_sha: "4554456"
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files.outputs) }}"
shell:
bash
- name: Run changed-files-specific with non existent base sha
id: changed-files-specific
uses: ./
continue-on-error: true
with:
files: action.yml
base_sha: "4554456"
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-specific.outputs) }}"
shell:
bash
test-non-existent-sha:
name: Test changed-files non existent sha
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest, macos-11, ubuntu-18.04, windows-2022, windows-2016]
steps:
- name: Checkout to branch
uses: actions/checkout@v2
- name: Run changed-files with non existent sha
id: changed-files
uses: ./
continue-on-error: true
with:
base_sha: "4554456"
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files.outputs) }}"
shell:
bash
- name: Run changed-files-specific with non existent sha
id: changed-files-specific
uses: ./
continue-on-error: true
with:
files: action.yml
base_sha: "4554456"
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-specific.outputs) }}"
shell:
bash
test:
name: Test changed-files
@@ -379,15 +434,6 @@ jobs:
echo '${{ toJSON(steps.changed-files-custom-sha.outputs) }}'
shell:
bash
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v5
- uses: nrwl/last-successful-commit-action@v1
id: last_successful_commit
with:
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: ./
@@ -398,12 +444,25 @@ jobs:
echo '${{ toJSON(steps.changed-files-since-last-remote-commit.outputs) }}'
shell:
bash
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v5
if: github.event_name == 'pull_request'
- uses: nrwl/last-successful-commit-action@v1
id: last_successful_commit
if: github.event_name == 'pull_request'
with:
branch: ${{ steps.branch-name.outputs.base_ref_branch }}
workflow_id: 'test.yml'
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Run changed-files with a custom base sha
if: github.event_name == 'pull_request'
id: changed-files-custom-base-sha
uses: ./
with:
base_sha: ${{ steps.last_successful_commit.outputs.commit_hash }}
- name: Show output
if: github.event_name == 'pull_request'
run: |
echo '${{ toJSON(steps.changed-files-custom-base-sha.outputs) }}'
shell:

View File

@@ -9,7 +9,7 @@ jobs:
sync-assets:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v2.4.0
with:
fetch-depth: 0

View File

@@ -1,5 +1,68 @@
# Changelog
## [v11.7](https://github.com/tj-actions/changed-files/tree/v11.7) (2021-11-19)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v1.2.2...v11.7)
**Merged pull requests:**
- Upgraded to v1.2.2 [\#256](https://github.com/tj-actions/changed-files/pull/256) ([jackton1](https://github.com/jackton1))
## [v1.2.2](https://github.com/tj-actions/changed-files/tree/v1.2.2) (2021-11-19)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v11.6...v1.2.2)
**Fixed bugs:**
- \[BUG\] pull request with `since_last_remote_commit = true` returns fatal: bad object [\#253](https://github.com/tj-actions/changed-files/issues/253)
**Closed issues:**
- Dependency Dashboard [\#27](https://github.com/tj-actions/changed-files/issues/27)
**Merged pull requests:**
- Updated git fetch to pull the last remote commit [\#254](https://github.com/tj-actions/changed-files/pull/254) ([jackton1](https://github.com/jackton1))
- Update reviewdog/action-shellcheck action to v1.12 [\#252](https://github.com/tj-actions/changed-files/pull/252) ([renovate[bot]](https://github.com/apps/renovate))
- Update reviewdog/action-shellcheck action to v1.11 [\#250](https://github.com/tj-actions/changed-files/pull/250) ([renovate[bot]](https://github.com/apps/renovate))
- Upgraded to v11.6 [\#249](https://github.com/tj-actions/changed-files/pull/249) ([jackton1](https://github.com/jackton1))
## [v11.6](https://github.com/tj-actions/changed-files/tree/v11.6) (2021-11-08)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v1.2.1...v11.6)
**Merged pull requests:**
- Upgraded to v1.2.1 [\#248](https://github.com/tj-actions/changed-files/pull/248) ([jackton1](https://github.com/jackton1))
## [v1.2.1](https://github.com/tj-actions/changed-files/tree/v1.2.1) (2021-11-08)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v11.5...v1.2.1)
**Implemented enhancements:**
- \[Feature\] Improve documentation [\#244](https://github.com/tj-actions/changed-files/issues/244)
**Merged pull requests:**
- Updated formatting of all modified debug message [\#247](https://github.com/tj-actions/changed-files/pull/247) ([jackton1](https://github.com/jackton1))
- Update reviewdog/action-shellcheck action to v1.10 [\#246](https://github.com/tj-actions/changed-files/pull/246) ([renovate[bot]](https://github.com/apps/renovate))
- Update peter-evans/create-pull-request action to v3.11.0 [\#245](https://github.com/tj-actions/changed-files/pull/245) ([renovate[bot]](https://github.com/apps/renovate))
- Update actions/checkout action to v2.4.0 [\#243](https://github.com/tj-actions/changed-files/pull/243) ([renovate[bot]](https://github.com/apps/renovate))
- Upgraded to v11.5 [\#241](https://github.com/tj-actions/changed-files/pull/241) ([jackton1](https://github.com/jackton1))
## [v11.5](https://github.com/tj-actions/changed-files/tree/v11.5) (2021-10-30)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v1.2.0...v11.5)
## [v1.2.0](https://github.com/tj-actions/changed-files/tree/v1.2.0) (2021-10-30)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v11.4...v1.2.0)
**Merged pull requests:**
- Upgraded to v11.4 [\#239](https://github.com/tj-actions/changed-files/pull/239) ([jackton1](https://github.com/jackton1))
## [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.3...v11.4)
@@ -67,10 +130,6 @@
- \[BUG\] Spaces in file names are not handled correctly [\#216](https://github.com/tj-actions/changed-files/issues/216)
- \[BUG\] Usage of quotes around array items [\#208](https://github.com/tj-actions/changed-files/issues/208)
**Closed issues:**
- Dependency Dashboard [\#27](https://github.com/tj-actions/changed-files/issues/27)
**Merged pull requests:**
- Updated README.md [\#221](https://github.com/tj-actions/changed-files/pull/221) ([jackton1](https://github.com/jackton1))

View File

@@ -1,4 +1,5 @@
[![CI](https://github.com/tj-actions/changed-files/actions/workflows/test.yml/badge.svg)](https://github.com/tj-actions/changed-files/actions/workflows/test.yml) [![Update release version.](https://github.com/tj-actions/changed-files/actions/workflows/sync-release-version.yml/badge.svg)](https://github.com/tj-actions/changed-files/actions/workflows/sync-release-version.yml) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/a3822d6c37f644bc99a5faa0bfb9c2c1)](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) [![Public workflows that use this action.](https://img.shields.io/endpoint?url=https%3A%2F%2Fapi-tj-actions1.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3Dtj-actions%2Fchanged-files%26badge%3Dtrue)](https://github.com/search?o=desc\&q=tj-actions+changed-files+language%3AYAML\&s=\&type=Code)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/4a625e9b62794b5b98e169c15c0e673c)](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)
[![CI](https://github.com/tj-actions/changed-files/actions/workflows/test.yml/badge.svg)](https://github.com/tj-actions/changed-files/actions/workflows/test.yml) [![Update release version.](https://github.com/tj-actions/changed-files/actions/workflows/sync-release-version.yml/badge.svg)](https://github.com/tj-actions/changed-files/actions/workflows/sync-release-version.yml) [![Public workflows that use this action.](https://img.shields.io/endpoint?url=https%3A%2F%2Fapi-tj-actions1.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3Dtj-actions%2Fchanged-files%26badge%3Dtrue)](https://github.com/search?o=desc\&q=tj-actions+changed-files+language%3AYAML\&s=\&type=Code)
[![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?logo=ubuntu\&logoColor=white)](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)
[![Mac OS](https://img.shields.io/badge/mac%20os-000000?logo=macos\&logoColor=F0F0F0)](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)
@@ -12,7 +13,7 @@
## changed-files
Retrieve all changed files relative to the default branch (`pull_request*` based events) or a previous commit (`push` based event) returning the **absolute path** to all changed files from the project root.
Retrieve all changed files relative to the default branch (`pull_request*` based events) or the last remote commit (`push` based event) returning the **absolute path** to all changed files from the project root.
## Features
@@ -22,10 +23,12 @@ Retrieve all changed files relative to the default branch (`pull_request*` based
* Multiple repositories.
* Self hosted runners.
* GitHub Enterprise Server.
* Monorepos (Fetches only the last remote commit)
* Supports all platforms.
* List all files that have changed.
* Between the current pull request branch and the default branch.
* Between the last commit and the current pushed change.
* Between the last remote branch commit and the current HEAD.
* Restrict change detection to a subset of files.
* Report on files that have at least one change.
* [Regex pattern](https://www.gnu.org/software/grep/manual/grep.html#Regular-Expressions) matching on a subset of files.
@@ -36,6 +39,7 @@ Retrieve all changed files relative to the default branch (`pull_request*` based
>
> * **IMPORTANT:** For `push` events you need to include `fetch-depth: 0` **OR** `fetch-depth: 2` depending on your use case.
> * When using `persist-credentials: false` with `actions/checkout@v2` you'll need to specify a `token` using the `token` input.
> * For monorepos were pulling all the branch history might not be desired the `fetch-depth` can be omitted for `pull_request` events.
```yaml
name: CI
@@ -59,7 +63,7 @@ jobs:
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v11.4
uses: tj-actions/changed-files@v11.7
- name: List all modified files
run: |
@@ -68,6 +72,16 @@ jobs:
done
```
If you feel generous and want to show some extra appreciation:
Support this project with a :star:
[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]
[buymeacoffee]: https://www.buymeacoffee.com/jackton1
[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png
## Outputs
| Acronym | Meaning |
@@ -111,7 +125,7 @@ jobs:
| 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). |
| since\_last\_remote\_commit | `string` | `false` | `false` | Use the last commit on the remote <br> branch as the `base_sha`.<br> (Defaults to the previous commit). <br /> NOTE: This requires <br /> `fetch-depth: 0`|
## Example
@@ -122,11 +136,11 @@ jobs:
- name: Get changed files using defaults
id: changed-files
uses: tj-actions/changed-files@v11.4
uses: tj-actions/changed-files@v11.7
- name: Get changed files using a comma separator
id: changed-files-comma
uses: tj-actions/changed-files@v11.4
uses: tj-actions/changed-files@v11.7
with:
separator: ","
@@ -148,7 +162,7 @@ jobs:
- name: Get specific changed files
id: changed-files-specific
uses: tj-actions/changed-files@v11.4
uses: tj-actions/changed-files@v11.7
with:
files: |
my-file.txt
@@ -186,14 +200,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.4
uses: tj-actions/changed-files@v11.7
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.4
uses: tj-actions/changed-files@v11.7
with:
files_from_source_file: |
test/changed-files-list.txt
@@ -202,13 +216,13 @@ jobs:
- name: Use a different commit SHA
id: changed-files-custom-sha
uses: tj-actions/changed-files@v11.4
uses: tj-actions/changed-files@v11.7
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.4
uses: tj-actions/changed-files@v11.7
with:
base_sha: "2096ed0"
@@ -220,7 +234,7 @@ jobs:
- name: Run changed-files with defaults on the dir1
id: changed-files-for-dir1
uses: tj-actions/changed-files@v11.4
uses: tj-actions/changed-files@v11.7
with:
path: dir1
@@ -230,9 +244,9 @@ jobs:
echo "$file was added"
done
- name: Run changed-files with since_last_remote_commit set to true
- name: Run changed-files using the last commit on the remote branch
id: changed-files-since-last-remote-commit
uses: tj-actions/changed-files@v11.4
uses: tj-actions/changed-files@v11.7
with:
since_last_remote_commit: 'true'
@@ -249,7 +263,7 @@ jobs:
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v11.4
uses: tj-actions/changed-files@v11.7
- name: Pre-commit
uses: pre-commit/action@v2.0.0
@@ -258,18 +272,10 @@ jobs:
token: ${{ secrets.github_token }}
```
![Screen Shot 2021-07-06 at 2 50 23 PM](https://user-images.githubusercontent.com/17484350/124651978-96ed5280-de69-11eb-86d5-396a4c1a980f.png)
![Screen Shot 2021-07-17 at 10 52 48 AM](https://user-images.githubusercontent.com/17484350/126040772-30b65afb-a6b5-4150-b312-ac2017ba7b98.png)
<img width="1147" alt="Screen Shot 2021-11-19 at 4 59 21 PM" src="https://user-images.githubusercontent.com/17484350/142696936-8b7ca955-7ef9-4d53-9bdf-3e0008e90c3f.png">
* Free software: [MIT license](LICENSE)
If you feel generous and want to show some extra appreciation:
Support me with a :star:
[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]
## Known Limitation
> NOTE: :warning:

View File

@@ -95,9 +95,12 @@ runs:
INPUT_FILES: ${{ inputs.files }}
INPUT_FILES_FROM_SOURCE_FILE: ${{ inputs.files_from_source_file }}
- run: |
# "Set base sha..."
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
elif [[ "${{ inputs.since_last_remote_commit }}" == "true" && "${{ github.event_name }}" == "pull_request" ]]; then
echo "::set-output name=base_sha::${{ github.event.pull_request.base.sha }}"
elif [[ "${{ inputs.since_last_remote_commit }}" == "true" && "${{ github.event_name }}" == "push" && "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]]; then
echo "::set-output name=base_sha::${{ github.event.before }}"
fi
id: base-sha

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -e
set -eu
echo "::group::changed-files"
@@ -24,6 +24,7 @@ git ls-remote --exit-code temp_changed_files 1>/dev/null 2>&1 && exit_status=$?
if [[ $exit_status -ne 0 ]]; then
echo "No 'temp_changed_files' remote found"
echo "Creating 'temp_changed_files' remote..."
git remote remove temp_changed_files 1>/dev/null || true
git remote add temp_changed_files "https://${INPUT_TOKEN}@${SERVER_URL}/${GITHUB_REPOSITORY}"
else
echo "Found 'temp_changed_files' remote"
@@ -37,8 +38,12 @@ else
CURRENT_SHA=$INPUT_SHA && exit_status=$? || exit_status=$?
fi
git rev-parse --quiet --verify "$CURRENT_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
if [[ $exit_status -ne 0 ]]; then
echo "::warning::Unable to determine the current head sha"
echo "::warning::Unable to locate the current sha: $CURRENT_SHA"
echo "::warning::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
git remote remove temp_changed_files
exit 1
fi
@@ -52,9 +57,11 @@ if [[ -z $GITHUB_BASE_REF ]]; then
else
PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$?
fi
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
if [[ $exit_status -ne 0 ]]; then
echo "::warning::Unable to determine the previous commit sha"
echo "::warning::Unable to locate the previous sha: $PREVIOUS_SHA"
echo "::warning::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
git remote remove temp_changed_files
exit 1
@@ -62,15 +69,20 @@ if [[ -z $GITHUB_BASE_REF ]]; then
else
TARGET_BRANCH=$GITHUB_BASE_REF
CURRENT_BRANCH=$GITHUB_HEAD_REF
git fetch temp_changed_files --no-tags -u "${TARGET_BRANCH}":"${TARGET_BRANCH}"
if [[ -z $INPUT_BASE_SHA ]]; then
git fetch --no-tags -u --progress --depth=1 temp_changed_files "${TARGET_BRANCH}":"${TARGET_BRANCH}" && exit_status=$? || exit_status=$?
PREVIOUS_SHA=$(git rev-parse "${TARGET_BRANCH}" 2>&1) && exit_status=$? || exit_status=$?
else
git fetch --no-tags -u --progress --depth=1 temp_changed_files "$INPUT_BASE_SHA" && exit_status=$? || exit_status=$?
PREVIOUS_SHA=$INPUT_BASE_SHA
fi
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
if [[ $exit_status -ne 0 ]]; then
echo "::warning::Unable to determine the base ref sha for ${TARGET_BRANCH}"
echo "::warning::Unable to locate the previous sha: $PREVIOUS_SHA"
echo "::warning::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
git remote remove temp_changed_files
exit 1
fi
@@ -78,8 +90,9 @@ fi
echo "Retrieving changes between $PREVIOUS_SHA ($TARGET_BRANCH) → $CURRENT_SHA ($CURRENT_BRANCH)"
echo "Getting diff..."
if [[ -z "${INPUT_FILES[*]}" ]]; then
echo "Getting diff..."
ADDED=$(git diff --diff-filter=A --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
COPIED=$(git diff --diff-filter=C --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
DELETED=$(git diff --diff-filter=D --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
@@ -91,7 +104,6 @@ if [[ -z "${INPUT_FILES[*]}" ]]; then
ALL_CHANGED_AND_MODIFIED=$(git diff --diff-filter="*ACDMRTUX" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
ALL_MODIFIED=$(git diff --diff-filter="ACMR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
else
echo "Input files: ${INPUT_FILES[*]}"
FILES=$(echo "${INPUT_FILES[*]}" | awk '{gsub(/ /,"\n"); print $0;}' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
@@ -119,9 +131,10 @@ else
fi
fi
echo "Matching modified files: ${UNIQUE_ALL_MODIFIED}"
UNIQUE_ALL_MODIFIED=$(echo "${UNIQUE_ALL_MODIFIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
if [[ -n "${UNIQUE_ALL_MODIFIED}" ]]; then
echo "Matching modified files: ${UNIQUE_ALL_MODIFIED}"
echo "::set-output name=any_changed::true"
else
echo "::set-output name=any_changed::false"

View File

@@ -1,4 +1,4 @@
.github/workflows/test.yml
action.yml
action.yml
test/changed-files-list.txt
action.yml