Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de0eba3279 | ||
|
|
bc262c2f61 | ||
|
|
d4389f0f4f | ||
|
|
79984462e1 | ||
|
|
c6dcc2a013 | ||
|
|
e6dde3c065 | ||
|
|
39283171ce | ||
|
|
33288d37e7 | ||
|
|
b60277dde9 |
40
HISTORY.md
40
HISTORY.md
@@ -1,5 +1,45 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
# [37.3.0](https://github.com/tj-actions/changed-files/compare/v37.2.0...v37.3.0) - (2023-07-19)
|
||||||
|
|
||||||
|
## <!-- 0 -->🚀 Features
|
||||||
|
|
||||||
|
- Add support for restricting recoverable deleted files via patterns ([#1390](https://github.com/tj-actions/changed-files/issues/1390)) ([33288d3](https://github.com/tj-actions/changed-files/commit/33288d37e78121ba601151ba03d8dacaf856777c)) - (Tonye Jack)
|
||||||
|
|
||||||
|
## <!-- 26 -->🔄 Update
|
||||||
|
|
||||||
|
- Updated README.md ([#1391](https://github.com/tj-actions/changed-files/issues/1391))
|
||||||
|
|
||||||
|
Co-authored-by: repo-ranger[bot] <repo-ranger[bot]@users.noreply.github.com> ([3928317](https://github.com/tj-actions/changed-files/commit/39283171cefdf491e0f0d6cf285b86b31eb6f3cd)) - (tj-actions[bot])
|
||||||
|
|
||||||
|
## <!-- 9 -->⬆️ Upgrades
|
||||||
|
|
||||||
|
- Upgraded to v37.2.0 ([#1389](https://github.com/tj-actions/changed-files/issues/1389))
|
||||||
|
|
||||||
|
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([b60277d](https://github.com/tj-actions/changed-files/commit/b60277dde98548f8d384a0b92a469fc5d0f46b1f)) - (tj-actions[bot])
|
||||||
|
|
||||||
|
# [37.2.0](https://github.com/tj-actions/changed-files/compare/v37.1.2...v37.2.0) - (2023-07-18)
|
||||||
|
|
||||||
|
## <!-- 26 -->🔄 Update
|
||||||
|
|
||||||
|
- Update README.md ([e3ea6b7](https://github.com/tj-actions/changed-files/commit/e3ea6b7948826820cfd616fda2d9c974a4ead314)) - (Tonye Jack)
|
||||||
|
|
||||||
|
## <!-- 7 -->⚙️ Miscellaneous Tasks
|
||||||
|
|
||||||
|
- **deps:** Update dependency eslint-plugin-github to v4.9.2 ([#1388](https://github.com/tj-actions/changed-files/issues/1388)) ([68b429d](https://github.com/tj-actions/changed-files/commit/68b429ddc666ea0dba46309e1ee45e06bb408df8)) - (renovate[bot])
|
||||||
|
- Switch to use the github context ([#1386](https://github.com/tj-actions/changed-files/issues/1386)) ([ec0b6d0](https://github.com/tj-actions/changed-files/commit/ec0b6d0e4c2965e4073849cbd0ab0e6fd3b42d50)) - (Tonye Jack)
|
||||||
|
- **deps:** Update dependency eslint-plugin-github to v4.9.1 ([#1387](https://github.com/tj-actions/changed-files/issues/1387)) ([8c8be23](https://github.com/tj-actions/changed-files/commit/8c8be234b2ced36de48c003dd2b2b0cd3448985f)) - (renovate[bot])
|
||||||
|
- **deps:** Update typescript-eslint monorepo to v6.1.0 ([#1385](https://github.com/tj-actions/changed-files/issues/1385)) ([029d6cd](https://github.com/tj-actions/changed-files/commit/029d6cd6b8191709b7e3d2bff0207a58a0c9c272)) - (renovate[bot])
|
||||||
|
- **deps:** Lock file maintenance ([#1383](https://github.com/tj-actions/changed-files/issues/1383)) ([8fc95ea](https://github.com/tj-actions/changed-files/commit/8fc95ea17520d70ecf9d3141ec0a0d8443780a48)) - (renovate[bot])
|
||||||
|
- **deps:** Lock file maintenance ([#1382](https://github.com/tj-actions/changed-files/issues/1382)) ([3e2a2ce](https://github.com/tj-actions/changed-files/commit/3e2a2ce2d08798ebef6a1b3b7fd8782820484ea4)) - (renovate[bot])
|
||||||
|
- **deps:** Update dependency eslint to v8.45.0 ([#1381](https://github.com/tj-actions/changed-files/issues/1381)) ([4aebdaf](https://github.com/tj-actions/changed-files/commit/4aebdafc0bbe1a3beffb6e7f6278d3323c6aabcb)) - (renovate[bot])
|
||||||
|
|
||||||
|
## <!-- 9 -->⬆️ Upgrades
|
||||||
|
|
||||||
|
- Upgraded to v37.1.2 ([#1378](https://github.com/tj-actions/changed-files/issues/1378))
|
||||||
|
|
||||||
|
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([2aadab2](https://github.com/tj-actions/changed-files/commit/2aadab2297933ef2a8eaa3a3316ae458aafe4964)) - (tj-actions[bot])
|
||||||
|
|
||||||
# [37.1.2](https://github.com/tj-actions/changed-files/compare/v37.1.1...v37.1.2) - (2023-07-13)
|
# [37.1.2](https://github.com/tj-actions/changed-files/compare/v37.1.1...v37.1.2) - (2023-07-13)
|
||||||
|
|
||||||
## <!-- 1 -->🐛 Bug Fixes
|
## <!-- 1 -->🐛 Bug Fixes
|
||||||
|
|||||||
152
README.md
152
README.md
@@ -110,46 +110,17 @@ jobs:
|
|||||||
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
|
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
|
||||||
|
|
||||||
# Example 1
|
# Example 1
|
||||||
- name: Get changed files
|
|
||||||
id: changed-files
|
|
||||||
uses: tj-actions/changed-files@v37
|
|
||||||
|
|
||||||
# To compare changes between the current commit and the last pushed remote commit set `since_last_remote_commit: true`. e.g
|
|
||||||
# with:
|
|
||||||
# since_last_remote_commit: true
|
|
||||||
|
|
||||||
- name: List all changed files
|
|
||||||
run: |
|
|
||||||
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
|
|
||||||
echo "$file was changed"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Example 2
|
|
||||||
- name: Get changed files in the docs folder
|
|
||||||
id: changed-files-specific
|
|
||||||
uses: tj-actions/changed-files@v37
|
|
||||||
with:
|
|
||||||
files: docs/*.{js,html} # Alternatively using: `docs/**` or `docs`
|
|
||||||
files_ignore: docs/static.js
|
|
||||||
|
|
||||||
- name: Run step if any file(s) in the docs folder change
|
|
||||||
if: steps.changed-files-specific.outputs.any_changed == 'true'
|
|
||||||
run: |
|
|
||||||
echo "One or more files in the docs folder has changed."
|
|
||||||
echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }}"
|
|
||||||
|
|
||||||
# Example 3
|
|
||||||
- name: Get all test, doc and src files that have changed
|
- name: Get all test, doc and src files that have changed
|
||||||
id: changed-files-yaml
|
id: changed-files-yaml
|
||||||
uses: tj-actions/changed-files@v37
|
uses: tj-actions/changed-files@v37
|
||||||
with:
|
with:
|
||||||
files_yaml: |
|
files_yaml: |
|
||||||
doc:
|
doc:
|
||||||
- **.md
|
- '**.md'
|
||||||
- docs/**
|
- 'docs/**'
|
||||||
- !docs/README.md
|
- !docs/README.md
|
||||||
test:
|
test:
|
||||||
- test/**
|
- 'test/**'
|
||||||
- !test/README.md
|
- !test/README.md
|
||||||
src:
|
src:
|
||||||
- src/**
|
- src/**
|
||||||
@@ -166,6 +137,35 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "One or more doc file(s) has changed."
|
echo "One or more doc file(s) has changed."
|
||||||
echo "List all the files that have changed: ${{ steps.changed-files-yaml.outputs.doc_all_changed_files }}"
|
echo "List all the files that have changed: ${{ steps.changed-files-yaml.outputs.doc_all_changed_files }}"
|
||||||
|
|
||||||
|
# Example 2
|
||||||
|
- name: Get changed files
|
||||||
|
id: changed-files
|
||||||
|
uses: tj-actions/changed-files@v37
|
||||||
|
|
||||||
|
# To compare changes between the current commit and the last pushed remote commit set `since_last_remote_commit: true`. e.g
|
||||||
|
# with:
|
||||||
|
# since_last_remote_commit: true
|
||||||
|
|
||||||
|
- name: List all changed files
|
||||||
|
run: |
|
||||||
|
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
|
||||||
|
echo "$file was changed"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Example 3
|
||||||
|
- name: Get changed files in the docs folder
|
||||||
|
id: changed-files-specific
|
||||||
|
uses: tj-actions/changed-files@v37
|
||||||
|
with:
|
||||||
|
files: docs/*.{js,html} # Alternatively using: `docs/**` or `docs`
|
||||||
|
files_ignore: docs/static.js
|
||||||
|
|
||||||
|
- name: Run step if any file(s) in the docs folder change
|
||||||
|
if: steps.changed-files-specific.outputs.any_changed == 'true'
|
||||||
|
run: |
|
||||||
|
echo "One or more files in the docs folder has changed."
|
||||||
|
echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }}"
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Using Github's API
|
#### Using Github's API
|
||||||
@@ -343,48 +343,52 @@ Support this project with a :star:
|
|||||||
|
|
||||||
<!-- AUTO-DOC-INPUT:START - Do not remove or modify this section -->
|
<!-- AUTO-DOC-INPUT:START - Do not remove or modify this section -->
|
||||||
|
|
||||||
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
|
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
|
||||||
|----------------------------------------------|--------|----------|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|----------------------------------------------|--------|----------|---------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| api\_url | string | false | `"${{ github.api_url }}"` | Github API URL. |
|
| api\_url | string | false | `"${{ github.api_url }}"` | Github API URL. |
|
||||||
| base\_sha | string | false | | Specify a different base commit <br>SHA used for comparing changes |
|
| base\_sha | string | false | | Specify a different base commit <br>SHA used for comparing changes |
|
||||||
| diff\_relative | string | false | `"true"` | Exclude changes outside the current <br>directory and show path names <br>relative to it. **NOTE:** This <br>requires you to specify the <br>top level directory via the <br>`path` input. |
|
| diff\_relative | string | false | `"true"` | Exclude changes outside the current <br>directory and show path names <br>relative to it. **NOTE:** This <br>requires you to specify the <br>top level directory via the <br>`path` input. |
|
||||||
| dir\_names | string | false | `"false"` | Output unique changed directories instead <br>of filenames. **NOTE:** This returns <br>`.` for changed files located <br>in the current working directory <br>which defaults to `$GITHUB_WORKSPACE`. |
|
| dir\_names | string | false | `"false"` | Output unique changed directories instead <br>of filenames. **NOTE:** This returns <br>`.` for changed files located <br>in the current working directory <br>which defaults to `$GITHUB_WORKSPACE`. |
|
||||||
| dir\_names\_exclude\_current\_dir | string | false | `"false"` | Exclude the current directory represented <br>by `.` from the output <br>when `dir_names` is set to <br>`true`. |
|
| dir\_names\_exclude\_current\_dir | string | false | `"false"` | Exclude the current directory represented <br>by `.` from the output <br>when `dir_names` is set to <br>`true`. |
|
||||||
| dir\_names\_max\_depth | string | false | | Limit the directory output to <br>a maximum depth e.g `test/test1/test2` <br>with max depth of `2` <br>returns `test/test1`. |
|
| dir\_names\_max\_depth | string | false | | Limit the directory output to <br>a maximum depth e.g `test/test1/test2` <br>with max depth of `2` <br>returns `test/test1`. |
|
||||||
| escape\_json | string | false | `"true"` | Escape JSON output. |
|
| escape\_json | string | false | `"true"` | Escape JSON output. |
|
||||||
| fetch\_depth | string | false | `"50"` | Depth of additional branch history <br>fetched. **NOTE**: This can be <br>adjusted to resolve errors with <br>insufficient history. |
|
| fetch\_depth | string | false | `"50"` | Depth of additional branch history <br>fetched. **NOTE**: This can be <br>adjusted to resolve errors with <br>insufficient history. |
|
||||||
| files | string | false | | File and directory patterns used <br>to detect changes (Defaults to the entire repo if unset) **NOTE:** <br>Multiline file/directory patterns should not <br>include quotes. |
|
| files | string | false | | File and directory patterns used <br>to detect changes (Defaults to the entire repo if unset) **NOTE:** <br>Multiline file/directory patterns should not <br>include quotes. |
|
||||||
| files\_from\_source\_file | string | false | | Source file(s) used to populate <br>the `files` input. |
|
| files\_from\_source\_file | string | false | | Source file(s) used to populate <br>the `files` input. |
|
||||||
| files\_from\_source\_file\_separator | string | false | `"\n"` | Separator used to split the <br>`files_from_source_file` input |
|
| files\_from\_source\_file\_separator | string | false | `"\n"` | Separator used to split the <br>`files_from_source_file` input |
|
||||||
| files\_ignore | string | false | | Ignore changes to these file(s) <br>**NOTE:** Multiline file/directory patterns should <br>not include quotes. |
|
| files\_ignore | string | false | | Ignore changes to these file(s) <br>**NOTE:** Multiline file/directory patterns should <br>not include quotes. |
|
||||||
| files\_ignore\_from\_source\_file | string | false | | Source file(s) used to populate <br>the `files_ignore` input |
|
| files\_ignore\_from\_source\_file | string | false | | Source file(s) used to populate <br>the `files_ignore` input |
|
||||||
| files\_ignore\_from\_source\_file\_separator | string | false | `"\n"` | Separator used to split the <br>`files_ignore_from_source_file` input |
|
| files\_ignore\_from\_source\_file\_separator | string | false | `"\n"` | Separator used to split the <br>`files_ignore_from_source_file` input |
|
||||||
| files\_ignore\_separator | string | false | `"\n"` | Separator used to split the <br>`files_ignore` input |
|
| files\_ignore\_separator | string | false | `"\n"` | Separator used to split the <br>`files_ignore` input |
|
||||||
| files\_ignore\_yaml | string | false | | YAML used to define a <br>set of file patterns to <br>ignore changes |
|
| files\_ignore\_yaml | string | false | | YAML used to define a <br>set of file patterns to <br>ignore changes |
|
||||||
| files\_ignore\_yaml\_from\_source\_file | string | false | | Source file(s) used to populate <br>the `files_ignore_yaml` input. [Example](https://github.com/tj-actions/changed-files/blob/main/test/changed-files.yml) |
|
| files\_ignore\_yaml\_from\_source\_file | string | false | | Source file(s) used to populate <br>the `files_ignore_yaml` input. [Example](https://github.com/tj-actions/changed-files/blob/main/test/changed-files.yml) |
|
||||||
| files\_ignore\_yaml\_from\_source\_file\_separator | string | false | `"\n"` | Separator used to split the <br>`files_ignore_yaml_from_source_file` input |
|
| files\_ignore\_yaml\_from\_source\_file\_separator | string | false | `"\n"` | Separator used to split the <br>`files_ignore_yaml_from_source_file` input |
|
||||||
| files\_separator | string | false | `"\n"` | Separator used to split the <br>`files` input |
|
| files\_separator | string | false | `"\n"` | Separator used to split the <br>`files` input |
|
||||||
| files\_yaml | string | false | | YAML used to define a <br>set of file patterns to <br>detect changes |
|
| files\_yaml | string | false | | YAML used to define a <br>set of file patterns to <br>detect changes |
|
||||||
| files\_yaml\_from\_source\_file | string | false | | Source file(s) used to populate <br>the `files_yaml` input. [Example](https://github.com/tj-actions/changed-files/blob/main/test/changed-files.yml) |
|
| files\_yaml\_from\_source\_file | string | false | | Source file(s) used to populate <br>the `files_yaml` input. [Example](https://github.com/tj-actions/changed-files/blob/main/test/changed-files.yml) |
|
||||||
| files\_yaml\_from\_source\_file\_separator | string | false | `"\n"` | Separator used to split the <br>`files_yaml_from_source_file` input |
|
| files\_yaml\_from\_source\_file\_separator | string | false | `"\n"` | Separator used to split the <br>`files_yaml_from_source_file` input |
|
||||||
| include\_all\_old\_new\_renamed\_files | string | false | `"false"` | Include `all_old_new_renamed_files` output. Note this <br>can generate a large output <br>See: [#501](https://github.com/tj-actions/changed-files/issues/501). |
|
| include\_all\_old\_new\_renamed\_files | string | false | `"false"` | Include `all_old_new_renamed_files` output. Note this <br>can generate a large output <br>See: [#501](https://github.com/tj-actions/changed-files/issues/501). |
|
||||||
| json | string | false | `"false"` | Output list of changed files <br>in a JSON formatted string <br>which can be used for <br>matrix jobs. |
|
| json | string | false | `"false"` | Output list of changed files <br>in a JSON formatted string <br>which can be used for <br>matrix jobs. |
|
||||||
| old\_new\_files\_separator | string | false | `" "` | Split character for old and <br>new renamed filename pairs. |
|
| old\_new\_files\_separator | string | false | `" "` | Split character for old and <br>new renamed filename pairs. |
|
||||||
| old\_new\_separator | string | false | `","` | Split character for old and <br>new filename pairs. |
|
| old\_new\_separator | string | false | `","` | Split character for old and <br>new filename pairs. |
|
||||||
| output\_dir | string | false | `".github/outputs"` | Directory to store output files. |
|
| output\_dir | string | false | `".github/outputs"` | Directory to store output files. |
|
||||||
| output\_renamed\_files\_as\_deleted\_and\_added | string | false | `"false"` | Output renamed files as deleted <br>and added files. |
|
| output\_renamed\_files\_as\_deleted\_and\_added | string | false | `"false"` | Output renamed files as deleted <br>and added files. |
|
||||||
| path | string | false | `"."` | Specify a relative path under <br>`$GITHUB_WORKSPACE` to locate the repository. |
|
| path | string | false | `"."` | Specify a relative path under <br>`$GITHUB_WORKSPACE` to locate the repository. |
|
||||||
| quotepath | string | false | `"true"` | Use non-ascii characters to match <br>files and output the filenames <br>completely verbatim by setting this <br>to `false` |
|
| quotepath | string | false | `"true"` | Use non-ascii characters to match <br>files and output the filenames <br>completely verbatim by setting this <br>to `false` |
|
||||||
| recover\_deleted\_files | string | false | `"false"` | Recover deleted files. |
|
| recover\_deleted\_files | string | false | `"false"` | Recover deleted files. |
|
||||||
| recover\_deleted\_files\_to\_destination | string | false | | Recover deleted files to a <br>new destination directory, defaults to <br>the original location. |
|
| recover\_deleted\_files\_to\_destination | string | false | | Recover deleted files to a <br>new destination directory, defaults to <br>the original location. |
|
||||||
| separator | string | false | `" "` | Split character for output strings |
|
| recover\_files | string | false | | File and directory patterns used <br>to recover deleted files, defaults <br>to the patterns provided via <br>the `files`, `files_from_source_file`, `files_ignore` and <br>`files_ignore_from_source_file` inputs or all deleted <br>files if no patterns are <br>provided. |
|
||||||
| sha | string | false | | Specify a different commit SHA <br>used for comparing changes |
|
| recover\_files\_ignore | string | false | | File and directory patterns to <br>ignore when recovering deleted files. |
|
||||||
| since | string | false | | Get changed files for commits <br>whose timestamp is older than <br>the given time. |
|
| recover\_files\_ignore\_separator | string | false | `"\n"` | Separator used to split the <br>`recover_files_ignore` input |
|
||||||
| since\_last\_remote\_commit | string | false | `"false"` | Use the last commit on <br>the remote branch as the <br>`base_sha`. Defaults to the last <br>non-merge commit on the target <br>branch for pull request events <br>and the previous remote commit <br>of the current branch for <br>push events. |
|
| recover\_files\_separator | string | false | `"\n"` | Separator used to split the <br>`recover_files` input |
|
||||||
| skip\_initial\_fetch | string | false | `"false"` | Skip the initial fetch to <br>improve performance for shallow repositories. <br>**NOTE**: This could lead to <br>errors with missing history and <br>the intended use is limited <br>to when you've fetched the <br>history necessary to perform the <br>diff. |
|
| separator | string | false | `" "` | Split character for output strings |
|
||||||
| token | string | false | `"${{ github.token }}"` | Github token used to fetch <br>changed files from Github's API. |
|
| sha | string | false | | Specify a different commit SHA <br>used for comparing changes |
|
||||||
| until | string | false | | Get changed files for commits <br>whose timestamp is earlier than <br>the given time. |
|
| since | string | false | | Get changed files for commits <br>whose timestamp is older than <br>the given time. |
|
||||||
| write\_output\_files | string | false | `"false"` | Write outputs to the `output_dir` <br>defaults to `.github/outputs` folder. **NOTE:** <br>This creates a `.txt` file <br>by default and a `.json` <br>file if `json` is set <br>to `true`. |
|
| since\_last\_remote\_commit | string | false | `"false"` | Use the last commit on <br>the remote branch as the <br>`base_sha`. Defaults to the last <br>non-merge commit on the target <br>branch for pull request events <br>and the previous remote commit <br>of the current branch for <br>push events. |
|
||||||
|
| skip\_initial\_fetch | string | false | `"false"` | Skip the initial fetch to <br>improve performance for shallow repositories. <br>**NOTE**: This could lead to <br>errors with missing history and <br>the intended use is limited <br>to when you've fetched the <br>history necessary to perform the <br>diff. |
|
||||||
|
| token | string | false | `"${{ github.token }}"` | Github token used to fetch <br>changed files from Github's API. |
|
||||||
|
| until | string | false | | Get changed files for commits <br>whose timestamp is earlier than <br>the given time. |
|
||||||
|
| write\_output\_files | string | false | `"false"` | Write outputs to the `output_dir` <br>defaults to `.github/outputs` folder. **NOTE:** <br>This creates a `.txt` file <br>by default and a `.json` <br>file if `json` is set <br>to `true`. |
|
||||||
|
|
||||||
<!-- AUTO-DOC-INPUT:END -->
|
<!-- AUTO-DOC-INPUT:END -->
|
||||||
|
|
||||||
|
|||||||
16
action.yml
16
action.yml
@@ -152,6 +152,22 @@ inputs:
|
|||||||
description: "Recover deleted files to a new destination directory, defaults to the original location."
|
description: "Recover deleted files to a new destination directory, defaults to the original location."
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
|
recover_files:
|
||||||
|
description: "File and directory patterns used to recover deleted files, defaults to the patterns provided via the `files`, `files_from_source_file`, `files_ignore` and `files_ignore_from_source_file` inputs or all deleted files if no patterns are provided."
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
recover_files_separator:
|
||||||
|
description: "Separator used to split the `recover_files` input"
|
||||||
|
default: "\n"
|
||||||
|
required: false
|
||||||
|
recover_files_ignore:
|
||||||
|
description: "File and directory patterns to ignore when recovering deleted files."
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
recover_files_ignore_separator:
|
||||||
|
description: "Separator used to split the `recover_files_ignore` input"
|
||||||
|
default: "\n"
|
||||||
|
required: false
|
||||||
token:
|
token:
|
||||||
description: "Github token used to fetch changed files from Github's API."
|
description: "Github token used to fetch changed files from Github's API."
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
225
dist/index.js
generated
vendored
225
dist/index.js
generated
vendored
@@ -326,20 +326,12 @@ const utils_1 = __nccwpck_require__(918);
|
|||||||
const getOutputKey = (key, outputPrefix) => {
|
const getOutputKey = (key, outputPrefix) => {
|
||||||
return outputPrefix ? `${outputPrefix}_${key}` : key;
|
return outputPrefix ? `${outputPrefix}_${key}` : key;
|
||||||
};
|
};
|
||||||
const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffResult, filePatterns = [], outputPrefix = '' }) => __awaiter(void 0, void 0, void 0, function* () {
|
const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], outputPrefix = '' }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const allFilteredDiffFiles = yield (0, utils_1.getFilteredChangedFiles)({
|
const allFilteredDiffFiles = yield (0, utils_1.getFilteredChangedFiles)({
|
||||||
allDiffFiles,
|
allDiffFiles,
|
||||||
filePatterns
|
filePatterns
|
||||||
});
|
});
|
||||||
core.debug(`All filtered diff files: ${JSON.stringify(allFilteredDiffFiles)}`);
|
core.debug(`All filtered diff files: ${JSON.stringify(allFilteredDiffFiles)}`);
|
||||||
if (diffResult) {
|
|
||||||
yield (0, utils_1.recoverDeletedFiles)({
|
|
||||||
inputs,
|
|
||||||
workingDirectory,
|
|
||||||
deletedFiles: allFilteredDiffFiles[changedFiles_1.ChangeTypeEnum.Deleted],
|
|
||||||
sha: diffResult.previousSha
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const addedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
const addedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
@@ -1228,6 +1220,18 @@ const getInputs = () => {
|
|||||||
required: false
|
required: false
|
||||||
});
|
});
|
||||||
const recoverDeletedFilesToDestination = core.getInput('recover_deleted_files_to_destination', { required: false });
|
const recoverDeletedFilesToDestination = core.getInput('recover_deleted_files_to_destination', { required: false });
|
||||||
|
const recoverFiles = core.getInput('recover_files', { required: false });
|
||||||
|
const recoverFilesSeparator = core.getInput('recover_files_separator', {
|
||||||
|
required: false,
|
||||||
|
trimWhitespace: false
|
||||||
|
});
|
||||||
|
const recoverFilesIgnore = core.getInput('recover_files_ignore', {
|
||||||
|
required: false
|
||||||
|
});
|
||||||
|
const recoverFilesIgnoreSeparator = core.getInput('recover_files_ignore_separator', {
|
||||||
|
required: false,
|
||||||
|
trimWhitespace: false
|
||||||
|
});
|
||||||
const token = core.getInput('token', { required: false });
|
const token = core.getInput('token', { required: false });
|
||||||
const apiUrl = core.getInput('api_url', { required: false });
|
const apiUrl = core.getInput('api_url', { required: false });
|
||||||
const skipInitialFetch = core.getBooleanInput('skip_initial_fetch', {
|
const skipInitialFetch = core.getBooleanInput('skip_initial_fetch', {
|
||||||
@@ -1260,6 +1264,10 @@ const getInputs = () => {
|
|||||||
sinceLastRemoteCommit,
|
sinceLastRemoteCommit,
|
||||||
recoverDeletedFiles,
|
recoverDeletedFiles,
|
||||||
recoverDeletedFilesToDestination,
|
recoverDeletedFilesToDestination,
|
||||||
|
recoverFiles,
|
||||||
|
recoverFilesSeparator,
|
||||||
|
recoverFilesIgnore,
|
||||||
|
recoverFilesIgnoreSeparator,
|
||||||
includeAllOldNewRenamedFiles,
|
includeAllOldNewRenamedFiles,
|
||||||
oldNewSeparator,
|
oldNewSeparator,
|
||||||
oldNewFilesSeparator,
|
oldNewFilesSeparator,
|
||||||
@@ -1339,6 +1347,40 @@ const commitSha_1 = __nccwpck_require__(8613);
|
|||||||
const env_1 = __nccwpck_require__(9763);
|
const env_1 = __nccwpck_require__(9763);
|
||||||
const inputs_1 = __nccwpck_require__(6180);
|
const inputs_1 = __nccwpck_require__(6180);
|
||||||
const utils_1 = __nccwpck_require__(918);
|
const utils_1 = __nccwpck_require__(918);
|
||||||
|
const changedFilesOutput = ({ filePatterns, allDiffFiles, inputs, yamlFilePatterns }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
if (filePatterns.length > 0) {
|
||||||
|
core.startGroup('changed-files-patterns');
|
||||||
|
yield (0, changedFilesOutput_1.setChangedFilesOutput)({
|
||||||
|
allDiffFiles,
|
||||||
|
filePatterns,
|
||||||
|
inputs
|
||||||
|
});
|
||||||
|
core.info('All Done!');
|
||||||
|
core.endGroup();
|
||||||
|
}
|
||||||
|
if (Object.keys(yamlFilePatterns).length > 0) {
|
||||||
|
for (const key of Object.keys(yamlFilePatterns)) {
|
||||||
|
core.startGroup(`changed-files-yaml-${key}`);
|
||||||
|
yield (0, changedFilesOutput_1.setChangedFilesOutput)({
|
||||||
|
allDiffFiles,
|
||||||
|
filePatterns: yamlFilePatterns[key],
|
||||||
|
outputPrefix: key,
|
||||||
|
inputs
|
||||||
|
});
|
||||||
|
core.info('All Done!');
|
||||||
|
core.endGroup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (filePatterns.length === 0 && Object.keys(yamlFilePatterns).length === 0) {
|
||||||
|
core.startGroup('changed-files-all');
|
||||||
|
yield (0, changedFilesOutput_1.setChangedFilesOutput)({
|
||||||
|
allDiffFiles,
|
||||||
|
inputs
|
||||||
|
});
|
||||||
|
core.info('All Done!');
|
||||||
|
core.endGroup();
|
||||||
|
}
|
||||||
|
});
|
||||||
const getChangedFilesFromLocalGit = ({ inputs, env, workingDirectory, filePatterns, yamlFilePatterns }) => __awaiter(void 0, void 0, void 0, function* () {
|
const getChangedFilesFromLocalGit = ({ inputs, env, workingDirectory, filePatterns, yamlFilePatterns }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c;
|
||||||
yield (0, utils_1.verifyMinimumGitVersion)();
|
yield (0, utils_1.verifyMinimumGitVersion)();
|
||||||
@@ -1393,44 +1435,26 @@ const getChangedFilesFromLocalGit = ({ inputs, env, workingDirectory, filePatter
|
|||||||
core.debug(`All diff files: ${JSON.stringify(allDiffFiles)}`);
|
core.debug(`All diff files: ${JSON.stringify(allDiffFiles)}`);
|
||||||
core.info('All Done!');
|
core.info('All Done!');
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
if (filePatterns.length > 0) {
|
if (inputs.recoverDeletedFiles) {
|
||||||
core.startGroup('changed-files-patterns');
|
let recoverPatterns = (0, utils_1.getRecoverFilePatterns)({ inputs });
|
||||||
yield (0, changedFilesOutput_1.setChangedFilesOutput)({
|
if (recoverPatterns.length > 0 && filePatterns.length > 0) {
|
||||||
allDiffFiles,
|
core.info('No recover patterns found; defaulting to file patterns');
|
||||||
filePatterns,
|
recoverPatterns = filePatterns;
|
||||||
inputs,
|
|
||||||
workingDirectory,
|
|
||||||
diffResult
|
|
||||||
});
|
|
||||||
core.info('All Done!');
|
|
||||||
core.endGroup();
|
|
||||||
}
|
|
||||||
if (Object.keys(yamlFilePatterns).length > 0) {
|
|
||||||
for (const key of Object.keys(yamlFilePatterns)) {
|
|
||||||
core.startGroup(`changed-files-yaml-${key}`);
|
|
||||||
yield (0, changedFilesOutput_1.setChangedFilesOutput)({
|
|
||||||
allDiffFiles,
|
|
||||||
filePatterns: yamlFilePatterns[key],
|
|
||||||
outputPrefix: key,
|
|
||||||
inputs,
|
|
||||||
workingDirectory,
|
|
||||||
diffResult
|
|
||||||
});
|
|
||||||
core.info('All Done!');
|
|
||||||
core.endGroup();
|
|
||||||
}
|
}
|
||||||
}
|
yield (0, utils_1.recoverDeletedFiles)({
|
||||||
if (filePatterns.length === 0 && Object.keys(yamlFilePatterns).length === 0) {
|
|
||||||
core.startGroup('changed-files-all');
|
|
||||||
yield (0, changedFilesOutput_1.setChangedFilesOutput)({
|
|
||||||
allDiffFiles,
|
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
diffResult
|
deletedFiles: allDiffFiles[changedFiles_1.ChangeTypeEnum.Deleted],
|
||||||
|
recoverPatterns,
|
||||||
|
sha: diffResult.previousSha
|
||||||
});
|
});
|
||||||
core.info('All Done!');
|
|
||||||
core.endGroup();
|
|
||||||
}
|
}
|
||||||
|
yield changedFilesOutput({
|
||||||
|
filePatterns,
|
||||||
|
allDiffFiles,
|
||||||
|
inputs,
|
||||||
|
yamlFilePatterns
|
||||||
|
});
|
||||||
if (inputs.includeAllOldNewRenamedFiles) {
|
if (inputs.includeAllOldNewRenamedFiles) {
|
||||||
core.startGroup('changed-files-all-old-new-renamed-files');
|
core.startGroup('changed-files-all-old-new-renamed-files');
|
||||||
const allOldNewRenamedFiles = yield (0, changedFiles_1.getRenamedFiles)({
|
const allOldNewRenamedFiles = yield (0, changedFiles_1.getRenamedFiles)({
|
||||||
@@ -1455,47 +1479,18 @@ const getChangedFilesFromLocalGit = ({ inputs, env, workingDirectory, filePatter
|
|||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const getChangedFilesFromRESTAPI = ({ inputs, workingDirectory, filePatterns, yamlFilePatterns }) => __awaiter(void 0, void 0, void 0, function* () {
|
const getChangedFilesFromRESTAPI = ({ inputs, filePatterns, yamlFilePatterns }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const allDiffFiles = yield (0, changedFiles_1.getChangedFilesFromGithubAPI)({
|
const allDiffFiles = yield (0, changedFiles_1.getChangedFilesFromGithubAPI)({
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
core.debug(`All diff files: ${JSON.stringify(allDiffFiles)}`);
|
core.debug(`All diff files: ${JSON.stringify(allDiffFiles)}`);
|
||||||
core.info('All Done!');
|
core.info('All Done!');
|
||||||
if (filePatterns.length > 0) {
|
yield changedFilesOutput({
|
||||||
core.startGroup('changed-files-patterns');
|
filePatterns,
|
||||||
yield (0, changedFilesOutput_1.setChangedFilesOutput)({
|
allDiffFiles,
|
||||||
allDiffFiles,
|
inputs,
|
||||||
filePatterns,
|
yamlFilePatterns
|
||||||
inputs,
|
});
|
||||||
workingDirectory
|
|
||||||
});
|
|
||||||
core.info('All Done!');
|
|
||||||
core.endGroup();
|
|
||||||
}
|
|
||||||
if (Object.keys(yamlFilePatterns).length > 0) {
|
|
||||||
for (const key of Object.keys(yamlFilePatterns)) {
|
|
||||||
core.startGroup(`changed-files-yaml-${key}`);
|
|
||||||
yield (0, changedFilesOutput_1.setChangedFilesOutput)({
|
|
||||||
allDiffFiles,
|
|
||||||
filePatterns: yamlFilePatterns[key],
|
|
||||||
outputPrefix: key,
|
|
||||||
inputs,
|
|
||||||
workingDirectory
|
|
||||||
});
|
|
||||||
core.info('All Done!');
|
|
||||||
core.endGroup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (filePatterns.length === 0 && Object.keys(yamlFilePatterns).length === 0) {
|
|
||||||
core.startGroup('changed-files-all');
|
|
||||||
yield (0, changedFilesOutput_1.setChangedFilesOutput)({
|
|
||||||
allDiffFiles,
|
|
||||||
inputs,
|
|
||||||
workingDirectory
|
|
||||||
});
|
|
||||||
core.info('All Done!');
|
|
||||||
core.endGroup();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
function run() {
|
function run() {
|
||||||
var _a;
|
var _a;
|
||||||
@@ -1505,8 +1500,7 @@ function run() {
|
|||||||
core.debug(`Env: ${JSON.stringify(env, null, 2)}`);
|
core.debug(`Env: ${JSON.stringify(env, null, 2)}`);
|
||||||
const inputs = (0, inputs_1.getInputs)();
|
const inputs = (0, inputs_1.getInputs)();
|
||||||
core.debug(`Inputs: ${JSON.stringify(inputs, null, 2)}`);
|
core.debug(`Inputs: ${JSON.stringify(inputs, null, 2)}`);
|
||||||
const githubContext = github.context;
|
core.debug(`Github Context: ${JSON.stringify(github.context, null, 2)}`);
|
||||||
core.debug(`Github Context: ${JSON.stringify(githubContext, null, 2)}`);
|
|
||||||
const workingDirectory = path_1.default.resolve(env.GITHUB_WORKSPACE || process.cwd(), inputs.path);
|
const workingDirectory = path_1.default.resolve(env.GITHUB_WORKSPACE || process.cwd(), inputs.path);
|
||||||
core.debug(`Working directory: ${workingDirectory}`);
|
core.debug(`Working directory: ${workingDirectory}`);
|
||||||
const hasGitDirectory = yield (0, utils_1.hasLocalGitDirectory)({ workingDirectory });
|
const hasGitDirectory = yield (0, utils_1.hasLocalGitDirectory)({ workingDirectory });
|
||||||
@@ -1542,7 +1536,6 @@ function run() {
|
|||||||
}
|
}
|
||||||
yield getChangedFilesFromRESTAPI({
|
yield getChangedFilesFromRESTAPI({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
|
||||||
filePatterns,
|
filePatterns,
|
||||||
yamlFilePatterns
|
yamlFilePatterns
|
||||||
});
|
});
|
||||||
@@ -1635,7 +1628,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.hasLocalGitDirectory = exports.recoverDeletedFiles = exports.setOutput = exports.getYamlFilePatterns = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentSha = exports.getRemoteBranchHeadSha = exports.isInsideWorkTree = exports.getHeadSha = exports.gitLog = exports.getFilteredChangedFiles = exports.getAllChangedFiles = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.verifyMinimumGitVersion = void 0;
|
exports.hasLocalGitDirectory = exports.recoverDeletedFiles = exports.setOutput = exports.getRecoverFilePatterns = exports.getYamlFilePatterns = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentSha = exports.getRemoteBranchHeadSha = exports.isInsideWorkTree = exports.getHeadSha = exports.gitLog = exports.getFilteredChangedFiles = exports.getAllChangedFiles = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.verifyMinimumGitVersion = void 0;
|
||||||
/*global AsyncIterableIterator*/
|
/*global AsyncIterableIterator*/
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const exec = __importStar(__nccwpck_require__(1514));
|
const exec = __importStar(__nccwpck_require__(1514));
|
||||||
@@ -2208,18 +2201,18 @@ const getYamlFilePatternsFromContents = ({ content = '', filePath = '', excluded
|
|||||||
const doc = (0, yaml_1.parseDocument)(source, { merge: true, schema: 'failsafe' });
|
const doc = (0, yaml_1.parseDocument)(source, { merge: true, schema: 'failsafe' });
|
||||||
if (doc.errors.length > 0) {
|
if (doc.errors.length > 0) {
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
core.warning(`YAML errors in ${filePath}: ${doc.errors}`);
|
throw new Error(`YAML errors in ${filePath}: ${doc.errors}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.warning(`YAML errors: ${doc.errors}`);
|
throw new Error(`YAML errors: ${doc.errors}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (doc.warnings.length > 0) {
|
if (doc.warnings.length > 0) {
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
core.warning(`YAML warnings in ${filePath}: ${doc.warnings}`);
|
throw new Error(`YAML warnings in ${filePath}: ${doc.warnings}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.warning(`YAML warnings: ${doc.warnings}`);
|
throw new Error(`YAML warnings: ${doc.warnings}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const yamlObject = doc.toJS();
|
const yamlObject = doc.toJS();
|
||||||
@@ -2303,6 +2296,23 @@ const getYamlFilePatterns = ({ inputs, workingDirectory }) => __awaiter(void 0,
|
|||||||
return filePatterns;
|
return filePatterns;
|
||||||
});
|
});
|
||||||
exports.getYamlFilePatterns = getYamlFilePatterns;
|
exports.getYamlFilePatterns = getYamlFilePatterns;
|
||||||
|
const getRecoverFilePatterns = ({ inputs }) => {
|
||||||
|
let filePatterns = inputs.recoverFiles.split(inputs.recoverFilesSeparator);
|
||||||
|
if (inputs.recoverFilesIgnore) {
|
||||||
|
const ignoreFilePatterns = inputs.recoverFilesIgnore.split(inputs.recoverFilesSeparator);
|
||||||
|
filePatterns = filePatterns.concat(ignoreFilePatterns.map(p => {
|
||||||
|
if (p.startsWith('!')) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return `!${p}`;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
core.debug(`recover file patterns: ${filePatterns}`);
|
||||||
|
return filePatterns.filter(Boolean);
|
||||||
|
};
|
||||||
|
exports.getRecoverFilePatterns = getRecoverFilePatterns;
|
||||||
const setOutput = ({ key, value, inputs }) => __awaiter(void 0, void 0, void 0, function* () {
|
const setOutput = ({ key, value, inputs }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const cleanedValue = value.toString().trim();
|
const cleanedValue = value.toString().trim();
|
||||||
core.setOutput(key, cleanedValue);
|
core.setOutput(key, cleanedValue);
|
||||||
@@ -2328,31 +2338,38 @@ const getDeletedFileContents = ({ cwd, filePath, sha }) => __awaiter(void 0, voi
|
|||||||
}
|
}
|
||||||
return stdout;
|
return stdout;
|
||||||
});
|
});
|
||||||
const recoverDeletedFiles = ({ inputs, workingDirectory, deletedFiles, sha }) => __awaiter(void 0, void 0, void 0, function* () {
|
const recoverDeletedFiles = ({ inputs, workingDirectory, deletedFiles, recoverPatterns, sha }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
if (inputs.recoverDeletedFiles) {
|
let recoverableDeletedFiles = deletedFiles;
|
||||||
for (const deletedFile of deletedFiles) {
|
core.debug(`recoverable deleted files: ${recoverableDeletedFiles}`);
|
||||||
let target = path.join(workingDirectory, deletedFile);
|
if (recoverPatterns.length > 0) {
|
||||||
if (inputs.recoverDeletedFilesToDestination) {
|
recoverableDeletedFiles = (0, micromatch_1.default)(deletedFiles, recoverPatterns, {
|
||||||
target = path.join(workingDirectory, inputs.recoverDeletedFilesToDestination, deletedFile);
|
dot: true,
|
||||||
}
|
windows: IS_WINDOWS,
|
||||||
const deletedFileContents = yield getDeletedFileContents({
|
noext: true
|
||||||
cwd: workingDirectory,
|
});
|
||||||
filePath: deletedFile,
|
core.debug(`filtered recoverable deleted files: ${recoverableDeletedFiles}`);
|
||||||
sha
|
}
|
||||||
});
|
for (const deletedFile of recoverableDeletedFiles) {
|
||||||
if (!(yield exists(path.dirname(target)))) {
|
let target = path.join(workingDirectory, deletedFile);
|
||||||
yield fs_1.promises.mkdir(path.dirname(target), { recursive: true });
|
if (inputs.recoverDeletedFilesToDestination) {
|
||||||
}
|
target = path.join(workingDirectory, inputs.recoverDeletedFilesToDestination, deletedFile);
|
||||||
yield fs_1.promises.writeFile(target, deletedFileContents);
|
|
||||||
}
|
}
|
||||||
|
const deletedFileContents = yield getDeletedFileContents({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
filePath: deletedFile,
|
||||||
|
sha
|
||||||
|
});
|
||||||
|
if (!(yield exists(path.dirname(target)))) {
|
||||||
|
yield fs_1.promises.mkdir(path.dirname(target), { recursive: true });
|
||||||
|
}
|
||||||
|
yield fs_1.promises.writeFile(target, deletedFileContents);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
exports.recoverDeletedFiles = recoverDeletedFiles;
|
exports.recoverDeletedFiles = recoverDeletedFiles;
|
||||||
const hasLocalGitDirectory = ({ workingDirectory }) => __awaiter(void 0, void 0, void 0, function* () {
|
const hasLocalGitDirectory = ({ workingDirectory }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const insideWorkTree = yield (0, exports.isInsideWorkTree)({
|
return yield (0, exports.isInsideWorkTree)({
|
||||||
cwd: workingDirectory
|
cwd: workingDirectory
|
||||||
});
|
});
|
||||||
return insideWorkTree;
|
|
||||||
});
|
});
|
||||||
exports.hasLocalGitDirectory = hasLocalGitDirectory;
|
exports.hasLocalGitDirectory = hasLocalGitDirectory;
|
||||||
|
|
||||||
|
|||||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -5,9 +5,8 @@ import {
|
|||||||
getAllChangeTypeFiles,
|
getAllChangeTypeFiles,
|
||||||
getChangeTypeFiles
|
getChangeTypeFiles
|
||||||
} from './changedFiles'
|
} from './changedFiles'
|
||||||
import {DiffResult} from './commitSha'
|
|
||||||
import {Inputs} from './inputs'
|
import {Inputs} from './inputs'
|
||||||
import {getFilteredChangedFiles, recoverDeletedFiles, setOutput} from './utils'
|
import {getFilteredChangedFiles, setOutput} from './utils'
|
||||||
|
|
||||||
const getOutputKey = (key: string, outputPrefix: string): string => {
|
const getOutputKey = (key: string, outputPrefix: string): string => {
|
||||||
return outputPrefix ? `${outputPrefix}_${key}` : key
|
return outputPrefix ? `${outputPrefix}_${key}` : key
|
||||||
@@ -16,15 +15,11 @@ const getOutputKey = (key: string, outputPrefix: string): string => {
|
|||||||
export const setChangedFilesOutput = async ({
|
export const setChangedFilesOutput = async ({
|
||||||
allDiffFiles,
|
allDiffFiles,
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
|
||||||
diffResult,
|
|
||||||
filePatterns = [],
|
filePatterns = [],
|
||||||
outputPrefix = ''
|
outputPrefix = ''
|
||||||
}: {
|
}: {
|
||||||
allDiffFiles: ChangedFiles
|
allDiffFiles: ChangedFiles
|
||||||
inputs: Inputs
|
inputs: Inputs
|
||||||
workingDirectory: string
|
|
||||||
diffResult?: DiffResult
|
|
||||||
filePatterns?: string[]
|
filePatterns?: string[]
|
||||||
outputPrefix?: string
|
outputPrefix?: string
|
||||||
}): Promise<void> => {
|
}): Promise<void> => {
|
||||||
@@ -34,15 +29,6 @@ export const setChangedFilesOutput = async ({
|
|||||||
})
|
})
|
||||||
core.debug(`All filtered diff files: ${JSON.stringify(allFilteredDiffFiles)}`)
|
core.debug(`All filtered diff files: ${JSON.stringify(allFilteredDiffFiles)}`)
|
||||||
|
|
||||||
if (diffResult) {
|
|
||||||
await recoverDeletedFiles({
|
|
||||||
inputs,
|
|
||||||
workingDirectory,
|
|
||||||
deletedFiles: allFilteredDiffFiles[ChangeTypeEnum.Deleted],
|
|
||||||
sha: diffResult.previousSha
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const addedFiles = await getChangeTypeFiles({
|
const addedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ export type Inputs = {
|
|||||||
outputRenamedFilesAsDeletedAndAdded: boolean
|
outputRenamedFilesAsDeletedAndAdded: boolean
|
||||||
recoverDeletedFiles: boolean
|
recoverDeletedFiles: boolean
|
||||||
recoverDeletedFilesToDestination: string
|
recoverDeletedFilesToDestination: string
|
||||||
|
recoverFiles: string
|
||||||
|
recoverFilesSeparator: string
|
||||||
|
recoverFilesIgnore: string
|
||||||
|
recoverFilesIgnoreSeparator: string
|
||||||
token: string
|
token: string
|
||||||
apiUrl: string
|
apiUrl: string
|
||||||
skipInitialFetch: boolean
|
skipInitialFetch: boolean
|
||||||
@@ -153,6 +157,21 @@ export const getInputs = (): Inputs => {
|
|||||||
'recover_deleted_files_to_destination',
|
'recover_deleted_files_to_destination',
|
||||||
{required: false}
|
{required: false}
|
||||||
)
|
)
|
||||||
|
const recoverFiles = core.getInput('recover_files', {required: false})
|
||||||
|
const recoverFilesSeparator = core.getInput('recover_files_separator', {
|
||||||
|
required: false,
|
||||||
|
trimWhitespace: false
|
||||||
|
})
|
||||||
|
const recoverFilesIgnore = core.getInput('recover_files_ignore', {
|
||||||
|
required: false
|
||||||
|
})
|
||||||
|
const recoverFilesIgnoreSeparator = core.getInput(
|
||||||
|
'recover_files_ignore_separator',
|
||||||
|
{
|
||||||
|
required: false,
|
||||||
|
trimWhitespace: false
|
||||||
|
}
|
||||||
|
)
|
||||||
const token = core.getInput('token', {required: false})
|
const token = core.getInput('token', {required: false})
|
||||||
const apiUrl = core.getInput('api_url', {required: false})
|
const apiUrl = core.getInput('api_url', {required: false})
|
||||||
const skipInitialFetch = core.getBooleanInput('skip_initial_fetch', {
|
const skipInitialFetch = core.getBooleanInput('skip_initial_fetch', {
|
||||||
@@ -186,6 +205,10 @@ export const getInputs = (): Inputs => {
|
|||||||
sinceLastRemoteCommit,
|
sinceLastRemoteCommit,
|
||||||
recoverDeletedFiles,
|
recoverDeletedFiles,
|
||||||
recoverDeletedFilesToDestination,
|
recoverDeletedFilesToDestination,
|
||||||
|
recoverFiles,
|
||||||
|
recoverFilesSeparator,
|
||||||
|
recoverFilesIgnore,
|
||||||
|
recoverFilesIgnoreSeparator,
|
||||||
includeAllOldNewRenamedFiles,
|
includeAllOldNewRenamedFiles,
|
||||||
oldNewSeparator,
|
oldNewSeparator,
|
||||||
oldNewFilesSeparator,
|
oldNewFilesSeparator,
|
||||||
|
|||||||
149
src/main.ts
149
src/main.ts
@@ -2,6 +2,8 @@ import * as core from '@actions/core'
|
|||||||
import * as github from '@actions/github'
|
import * as github from '@actions/github'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import {
|
import {
|
||||||
|
ChangedFiles,
|
||||||
|
ChangeTypeEnum,
|
||||||
getAllDiffFiles,
|
getAllDiffFiles,
|
||||||
getChangedFilesFromGithubAPI,
|
getChangedFilesFromGithubAPI,
|
||||||
getRenamedFiles
|
getRenamedFiles
|
||||||
@@ -16,16 +18,65 @@ import {Env, getEnv} from './env'
|
|||||||
import {getInputs, Inputs} from './inputs'
|
import {getInputs, Inputs} from './inputs'
|
||||||
import {
|
import {
|
||||||
getFilePatterns,
|
getFilePatterns,
|
||||||
|
getRecoverFilePatterns,
|
||||||
getSubmodulePath,
|
getSubmodulePath,
|
||||||
getYamlFilePatterns,
|
getYamlFilePatterns,
|
||||||
hasLocalGitDirectory,
|
hasLocalGitDirectory,
|
||||||
isRepoShallow,
|
isRepoShallow,
|
||||||
|
recoverDeletedFiles,
|
||||||
setOutput,
|
setOutput,
|
||||||
submoduleExists,
|
submoduleExists,
|
||||||
updateGitGlobalConfig,
|
updateGitGlobalConfig,
|
||||||
verifyMinimumGitVersion
|
verifyMinimumGitVersion
|
||||||
} from './utils'
|
} from './utils'
|
||||||
|
|
||||||
|
const changedFilesOutput = async ({
|
||||||
|
filePatterns,
|
||||||
|
allDiffFiles,
|
||||||
|
inputs,
|
||||||
|
yamlFilePatterns
|
||||||
|
}: {
|
||||||
|
filePatterns: string[]
|
||||||
|
allDiffFiles: ChangedFiles
|
||||||
|
inputs: Inputs
|
||||||
|
yamlFilePatterns: Record<string, string[]>
|
||||||
|
}): Promise<void> => {
|
||||||
|
if (filePatterns.length > 0) {
|
||||||
|
core.startGroup('changed-files-patterns')
|
||||||
|
await setChangedFilesOutput({
|
||||||
|
allDiffFiles,
|
||||||
|
filePatterns,
|
||||||
|
inputs
|
||||||
|
})
|
||||||
|
core.info('All Done!')
|
||||||
|
core.endGroup()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(yamlFilePatterns).length > 0) {
|
||||||
|
for (const key of Object.keys(yamlFilePatterns)) {
|
||||||
|
core.startGroup(`changed-files-yaml-${key}`)
|
||||||
|
await setChangedFilesOutput({
|
||||||
|
allDiffFiles,
|
||||||
|
filePatterns: yamlFilePatterns[key],
|
||||||
|
outputPrefix: key,
|
||||||
|
inputs
|
||||||
|
})
|
||||||
|
core.info('All Done!')
|
||||||
|
core.endGroup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filePatterns.length === 0 && Object.keys(yamlFilePatterns).length === 0) {
|
||||||
|
core.startGroup('changed-files-all')
|
||||||
|
await setChangedFilesOutput({
|
||||||
|
allDiffFiles,
|
||||||
|
inputs
|
||||||
|
})
|
||||||
|
core.info('All Done!')
|
||||||
|
core.endGroup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const getChangedFilesFromLocalGit = async ({
|
const getChangedFilesFromLocalGit = async ({
|
||||||
inputs,
|
inputs,
|
||||||
env,
|
env,
|
||||||
@@ -125,47 +176,30 @@ const getChangedFilesFromLocalGit = async ({
|
|||||||
core.info('All Done!')
|
core.info('All Done!')
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
|
||||||
if (filePatterns.length > 0) {
|
if (inputs.recoverDeletedFiles) {
|
||||||
core.startGroup('changed-files-patterns')
|
let recoverPatterns = getRecoverFilePatterns({inputs})
|
||||||
await setChangedFilesOutput({
|
|
||||||
allDiffFiles,
|
|
||||||
filePatterns,
|
|
||||||
inputs,
|
|
||||||
workingDirectory,
|
|
||||||
diffResult
|
|
||||||
})
|
|
||||||
core.info('All Done!')
|
|
||||||
core.endGroup()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Object.keys(yamlFilePatterns).length > 0) {
|
if (recoverPatterns.length > 0 && filePatterns.length > 0) {
|
||||||
for (const key of Object.keys(yamlFilePatterns)) {
|
core.info('No recover patterns found; defaulting to file patterns')
|
||||||
core.startGroup(`changed-files-yaml-${key}`)
|
recoverPatterns = filePatterns
|
||||||
await setChangedFilesOutput({
|
|
||||||
allDiffFiles,
|
|
||||||
filePatterns: yamlFilePatterns[key],
|
|
||||||
outputPrefix: key,
|
|
||||||
inputs,
|
|
||||||
workingDirectory,
|
|
||||||
diffResult
|
|
||||||
})
|
|
||||||
core.info('All Done!')
|
|
||||||
core.endGroup()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (filePatterns.length === 0 && Object.keys(yamlFilePatterns).length === 0) {
|
await recoverDeletedFiles({
|
||||||
core.startGroup('changed-files-all')
|
|
||||||
await setChangedFilesOutput({
|
|
||||||
allDiffFiles,
|
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
diffResult
|
deletedFiles: allDiffFiles[ChangeTypeEnum.Deleted],
|
||||||
|
recoverPatterns,
|
||||||
|
sha: diffResult.previousSha
|
||||||
})
|
})
|
||||||
core.info('All Done!')
|
|
||||||
core.endGroup()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await changedFilesOutput({
|
||||||
|
filePatterns,
|
||||||
|
allDiffFiles,
|
||||||
|
inputs,
|
||||||
|
yamlFilePatterns
|
||||||
|
})
|
||||||
|
|
||||||
if (inputs.includeAllOldNewRenamedFiles) {
|
if (inputs.includeAllOldNewRenamedFiles) {
|
||||||
core.startGroup('changed-files-all-old-new-renamed-files')
|
core.startGroup('changed-files-all-old-new-renamed-files')
|
||||||
const allOldNewRenamedFiles = await getRenamedFiles({
|
const allOldNewRenamedFiles = await getRenamedFiles({
|
||||||
@@ -193,12 +227,10 @@ const getChangedFilesFromLocalGit = async ({
|
|||||||
|
|
||||||
const getChangedFilesFromRESTAPI = async ({
|
const getChangedFilesFromRESTAPI = async ({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
|
||||||
filePatterns,
|
filePatterns,
|
||||||
yamlFilePatterns
|
yamlFilePatterns
|
||||||
}: {
|
}: {
|
||||||
inputs: Inputs
|
inputs: Inputs
|
||||||
workingDirectory: string
|
|
||||||
filePatterns: string[]
|
filePatterns: string[]
|
||||||
yamlFilePatterns: Record<string, string[]>
|
yamlFilePatterns: Record<string, string[]>
|
||||||
}): Promise<void> => {
|
}): Promise<void> => {
|
||||||
@@ -208,43 +240,12 @@ const getChangedFilesFromRESTAPI = async ({
|
|||||||
core.debug(`All diff files: ${JSON.stringify(allDiffFiles)}`)
|
core.debug(`All diff files: ${JSON.stringify(allDiffFiles)}`)
|
||||||
core.info('All Done!')
|
core.info('All Done!')
|
||||||
|
|
||||||
if (filePatterns.length > 0) {
|
await changedFilesOutput({
|
||||||
core.startGroup('changed-files-patterns')
|
filePatterns,
|
||||||
await setChangedFilesOutput({
|
allDiffFiles,
|
||||||
allDiffFiles,
|
inputs,
|
||||||
filePatterns,
|
yamlFilePatterns
|
||||||
inputs,
|
})
|
||||||
workingDirectory
|
|
||||||
})
|
|
||||||
core.info('All Done!')
|
|
||||||
core.endGroup()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Object.keys(yamlFilePatterns).length > 0) {
|
|
||||||
for (const key of Object.keys(yamlFilePatterns)) {
|
|
||||||
core.startGroup(`changed-files-yaml-${key}`)
|
|
||||||
await setChangedFilesOutput({
|
|
||||||
allDiffFiles,
|
|
||||||
filePatterns: yamlFilePatterns[key],
|
|
||||||
outputPrefix: key,
|
|
||||||
inputs,
|
|
||||||
workingDirectory
|
|
||||||
})
|
|
||||||
core.info('All Done!')
|
|
||||||
core.endGroup()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filePatterns.length === 0 && Object.keys(yamlFilePatterns).length === 0) {
|
|
||||||
core.startGroup('changed-files-all')
|
|
||||||
await setChangedFilesOutput({
|
|
||||||
allDiffFiles,
|
|
||||||
inputs,
|
|
||||||
workingDirectory
|
|
||||||
})
|
|
||||||
core.info('All Done!')
|
|
||||||
core.endGroup()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
@@ -256,8 +257,7 @@ export async function run(): Promise<void> {
|
|||||||
const inputs = getInputs()
|
const inputs = getInputs()
|
||||||
core.debug(`Inputs: ${JSON.stringify(inputs, null, 2)}`)
|
core.debug(`Inputs: ${JSON.stringify(inputs, null, 2)}`)
|
||||||
|
|
||||||
const githubContext = github.context
|
core.debug(`Github Context: ${JSON.stringify(github.context, null, 2)}`)
|
||||||
core.debug(`Github Context: ${JSON.stringify(githubContext, null, 2)}`)
|
|
||||||
|
|
||||||
const workingDirectory = path.resolve(
|
const workingDirectory = path.resolve(
|
||||||
env.GITHUB_WORKSPACE || process.cwd(),
|
env.GITHUB_WORKSPACE || process.cwd(),
|
||||||
@@ -306,7 +306,6 @@ export async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
await getChangedFilesFromRESTAPI({
|
await getChangedFilesFromRESTAPI({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
|
||||||
filePatterns,
|
filePatterns,
|
||||||
yamlFilePatterns
|
yamlFilePatterns
|
||||||
})
|
})
|
||||||
|
|||||||
92
src/utils.ts
92
src/utils.ts
@@ -893,17 +893,17 @@ const getYamlFilePatternsFromContents = async ({
|
|||||||
|
|
||||||
if (doc.errors.length > 0) {
|
if (doc.errors.length > 0) {
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
core.warning(`YAML errors in ${filePath}: ${doc.errors}`)
|
throw new Error(`YAML errors in ${filePath}: ${doc.errors}`)
|
||||||
} else {
|
} else {
|
||||||
core.warning(`YAML errors: ${doc.errors}`)
|
throw new Error(`YAML errors: ${doc.errors}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doc.warnings.length > 0) {
|
if (doc.warnings.length > 0) {
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
core.warning(`YAML warnings in ${filePath}: ${doc.warnings}`)
|
throw new Error(`YAML warnings in ${filePath}: ${doc.warnings}`)
|
||||||
} else {
|
} else {
|
||||||
core.warning(`YAML warnings: ${doc.warnings}`)
|
throw new Error(`YAML warnings: ${doc.warnings}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1028,6 +1028,36 @@ export const getYamlFilePatterns = async ({
|
|||||||
return filePatterns
|
return filePatterns
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getRecoverFilePatterns = ({
|
||||||
|
inputs
|
||||||
|
}: {
|
||||||
|
inputs: Inputs
|
||||||
|
}): string[] => {
|
||||||
|
let filePatterns: string[] = inputs.recoverFiles.split(
|
||||||
|
inputs.recoverFilesSeparator
|
||||||
|
)
|
||||||
|
|
||||||
|
if (inputs.recoverFilesIgnore) {
|
||||||
|
const ignoreFilePatterns = inputs.recoverFilesIgnore.split(
|
||||||
|
inputs.recoverFilesSeparator
|
||||||
|
)
|
||||||
|
|
||||||
|
filePatterns = filePatterns.concat(
|
||||||
|
ignoreFilePatterns.map(p => {
|
||||||
|
if (p.startsWith('!')) {
|
||||||
|
return p
|
||||||
|
} else {
|
||||||
|
return `!${p}`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
core.debug(`recover file patterns: ${filePatterns}`)
|
||||||
|
|
||||||
|
return filePatterns.filter(Boolean)
|
||||||
|
}
|
||||||
|
|
||||||
export const setOutput = async ({
|
export const setOutput = async ({
|
||||||
key,
|
key,
|
||||||
value,
|
value,
|
||||||
@@ -1084,36 +1114,48 @@ export const recoverDeletedFiles = async ({
|
|||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
deletedFiles,
|
deletedFiles,
|
||||||
|
recoverPatterns,
|
||||||
sha
|
sha
|
||||||
}: {
|
}: {
|
||||||
inputs: Inputs
|
inputs: Inputs
|
||||||
workingDirectory: string
|
workingDirectory: string
|
||||||
deletedFiles: string[]
|
deletedFiles: string[]
|
||||||
|
recoverPatterns: string[]
|
||||||
sha: string
|
sha: string
|
||||||
}): Promise<void> => {
|
}): Promise<void> => {
|
||||||
if (inputs.recoverDeletedFiles) {
|
let recoverableDeletedFiles = deletedFiles
|
||||||
for (const deletedFile of deletedFiles) {
|
core.debug(`recoverable deleted files: ${recoverableDeletedFiles}`)
|
||||||
let target = path.join(workingDirectory, deletedFile)
|
|
||||||
|
|
||||||
if (inputs.recoverDeletedFilesToDestination) {
|
if (recoverPatterns.length > 0) {
|
||||||
target = path.join(
|
recoverableDeletedFiles = mm(deletedFiles, recoverPatterns, {
|
||||||
workingDirectory,
|
dot: true,
|
||||||
inputs.recoverDeletedFilesToDestination,
|
windows: IS_WINDOWS,
|
||||||
deletedFile
|
noext: true
|
||||||
)
|
})
|
||||||
}
|
core.debug(`filtered recoverable deleted files: ${recoverableDeletedFiles}`)
|
||||||
|
}
|
||||||
|
|
||||||
const deletedFileContents = await getDeletedFileContents({
|
for (const deletedFile of recoverableDeletedFiles) {
|
||||||
cwd: workingDirectory,
|
let target = path.join(workingDirectory, deletedFile)
|
||||||
filePath: deletedFile,
|
|
||||||
sha
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!(await exists(path.dirname(target)))) {
|
if (inputs.recoverDeletedFilesToDestination) {
|
||||||
await fs.mkdir(path.dirname(target), {recursive: true})
|
target = path.join(
|
||||||
}
|
workingDirectory,
|
||||||
await fs.writeFile(target, deletedFileContents)
|
inputs.recoverDeletedFilesToDestination,
|
||||||
|
deletedFile
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const deletedFileContents = await getDeletedFileContents({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
filePath: deletedFile,
|
||||||
|
sha
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!(await exists(path.dirname(target)))) {
|
||||||
|
await fs.mkdir(path.dirname(target), {recursive: true})
|
||||||
|
}
|
||||||
|
await fs.writeFile(target, deletedFileContents)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1122,9 +1164,7 @@ export const hasLocalGitDirectory = async ({
|
|||||||
}: {
|
}: {
|
||||||
workingDirectory: string
|
workingDirectory: string
|
||||||
}): Promise<boolean> => {
|
}): Promise<boolean> => {
|
||||||
const insideWorkTree = await isInsideWorkTree({
|
return await isInsideWorkTree({
|
||||||
cwd: workingDirectory
|
cwd: workingDirectory
|
||||||
})
|
})
|
||||||
|
|
||||||
return insideWorkTree
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user