3
0
Fork 0
mirror of https://github.com/tj-actions/changed-files synced 2024-12-17 03:47:20 +00:00

Update README.md

This commit is contained in:
Tonye Jack 2023-12-23 04:59:15 -07:00 committed by GitHub
parent d13ac1942f
commit 6e79d6e3db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -708,6 +708,29 @@ The format of the version string is as follows:
</details> </details>
<details>
<summary>Get all changed files without escaping unsafe filename characters</summary>
```yaml
...
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40
with:
safe_output: false # set to false because we are using an environment variable to store the output and avoid command injection.
- name: List all added files
env:
ADDED_FILES: ${{ steps.changed-files.outputs.added_files }}
run: |
for file in "$ADDED_FILES"; do
echo "$file was added"
done
...
```
</details>
<details> <details>
<summary>Get all changed files and use a comma separator</summary> <summary>Get all changed files and use a comma separator</summary>
@ -733,13 +756,10 @@ See [inputs](#inputs) for more information.
- name: Get changed files - name: Get changed files
id: changed-files id: changed-files
uses: tj-actions/changed-files@v40 uses: tj-actions/changed-files@v40
with:
safe_output: false
- name: List all added files - name: List all added files
env: env:
ADDED_FILES: |- ADDED_FILES: ${{ steps.changed-files.outputs.added_files }}
${{ steps.changed-files.outputs.added_files }}
run: | run: |
for file in "$ADDED_FILES"; do for file in "$ADDED_FILES"; do
echo "$file was added" echo "$file was added"
@ -759,8 +779,6 @@ See [outputs](#outputs) for a list of all available outputs.
- name: Get changed files - name: Get changed files
id: changed-files id: changed-files
uses: tj-actions/changed-files@v40 uses: tj-actions/changed-files@v40
with:
safe_output: false
- name: Run a step if my-file.txt was modified - name: Run a step if my-file.txt was modified
if: contains(steps.changed-files.outputs.modified_files, 'my-file.txt') if: contains(steps.changed-files.outputs.modified_files, 'my-file.txt')
@ -783,7 +801,6 @@ See [outputs](#outputs) for a list of all available outputs.
id: changed-files-write-output-files-txt id: changed-files-write-output-files-txt
uses: tj-actions/changed-files@v40 uses: tj-actions/changed-files@v40
with: with:
safe_output: false
write_output_files: true write_output_files: true
- name: Verify the contents of the .github/outputs/added_files.txt file - name: Verify the contents of the .github/outputs/added_files.txt file
@ -803,7 +820,6 @@ See [outputs](#outputs) for a list of all available outputs.
id: changed-files-write-output-files-json id: changed-files-write-output-files-json
uses: tj-actions/changed-files@v40 uses: tj-actions/changed-files@v40
with: with:
safe_output: false
json: true json: true
write_output_files: true write_output_files: true
@ -847,7 +863,6 @@ See [inputs](#inputs) for more information.
id: changed-files-specific id: changed-files-specific
uses: tj-actions/changed-files@v40 uses: tj-actions/changed-files@v40
with: with:
safe_output: false
files: | files: |
my-file.txt my-file.txt
*.sh *.sh
@ -869,8 +884,7 @@ See [inputs](#inputs) for more information.
- name: Run step if any of the listed files above is deleted - name: Run step if any of the listed files above is deleted
if: steps.changed-files-specific.outputs.any_deleted == 'true' if: steps.changed-files-specific.outputs.any_deleted == 'true'
env: env:
DELETED_FILES: |- DELETED_FILES: ${{ steps.changed-files-specific.outputs.deleted_files }}
${{ steps.changed-files-specific.outputs.deleted_files }}
run: | run: |
for file in "$DELETED_FILES"; do for file in "$DELETED_FILES"; do
echo "$file was deleted" echo "$file was deleted"
@ -879,8 +893,7 @@ See [inputs](#inputs) for more information.
- name: Run step if all listed files above have been deleted - name: Run step if all listed files above have been deleted
if: steps.changed-files-specific.outputs.only_deleted == 'true' if: steps.changed-files-specific.outputs.only_deleted == 'true'
env: env:
DELETED_FILES: |- DELETED_FILES: ${{ steps.changed-files-specific.outputs.deleted_files }}
${{ steps.changed-files-specific.outputs.deleted_files }}
run: | run: |
for file in "$DELETED_FILES"; do for file in "$DELETED_FILES"; do
echo "$file was deleted" echo "$file was deleted"
@ -992,15 +1005,13 @@ jobs:
id: changed-files-specific id: changed-files-specific
uses: tj-actions/changed-files@v40 uses: tj-actions/changed-files@v40
with: with:
safe_output: false
base_sha: ${{ steps.get-base-sha.outputs.base_sha }} base_sha: ${{ steps.get-base-sha.outputs.base_sha }}
files: .github/** files: .github/**
- name: Run step if any file(s) in the .github folder change - name: Run step if any file(s) in the .github folder change
if: steps.changed-files-specific.outputs.any_changed == 'true' if: steps.changed-files-specific.outputs.any_changed == 'true'
env: env:
ALL_CHANGED_FILES: |- ALL_CHANGED_FILES: ${{ steps.changed-files-specific.outputs.all_changed_files }}
${{ steps.changed-files-specific.outputs.all_changed_files }}
run: | run: |
echo "One or more files in the .github folder has changed." echo "One or more files in the .github folder has changed."
echo "List all the files that have changed: $ALL_CHANGED_FILES" echo "List all the files that have changed: $ALL_CHANGED_FILES"
@ -1026,7 +1037,6 @@ See [inputs](#inputs) for more information.
id: changed-files-for-dir1 id: changed-files-for-dir1
uses: tj-actions/changed-files@v40 uses: tj-actions/changed-files@v40
with: with:
safe_output: false
path: dir1 path: dir1
- name: List all added files in dir1 - name: List all added files in dir1