Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 authored Dec 23, 2023
1 parent d13ac19 commit 6e79d6e
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,29 @@ The format of the version string is as follows:

</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>
<summary>Get all changed files and use a comma separator</summary>

Expand All @@ -733,13 +756,10 @@ See [inputs](#inputs) for more information.
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40
with:
safe_output: false

- name: List all added files
env:
ADDED_FILES: |-
${{ steps.changed-files.outputs.added_files }}
ADDED_FILES: ${{ steps.changed-files.outputs.added_files }}
run: |
for file in "$ADDED_FILES"; do
echo "$file was added"
Expand All @@ -759,8 +779,6 @@ See [outputs](#outputs) for a list of all available outputs.
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40
with:
safe_output: false

- name: Run a step if my-file.txt was modified
if: contains(steps.changed-files.outputs.modified_files, 'my-file.txt')
Expand All @@ -783,7 +801,6 @@ See [outputs](#outputs) for a list of all available outputs.
id: changed-files-write-output-files-txt
uses: tj-actions/changed-files@v40
with:
safe_output: false
write_output_files: true

- name: Verify the contents of the .github/outputs/added_files.txt file
Expand All @@ -803,7 +820,6 @@ See [outputs](#outputs) for a list of all available outputs.
id: changed-files-write-output-files-json
uses: tj-actions/changed-files@v40
with:
safe_output: false
json: true
write_output_files: true

Expand Down Expand Up @@ -847,7 +863,6 @@ See [inputs](#inputs) for more information.
id: changed-files-specific
uses: tj-actions/changed-files@v40
with:
safe_output: false
files: |
my-file.txt
*.sh
Expand All @@ -869,8 +884,7 @@ See [inputs](#inputs) for more information.
- name: Run step if any of the listed files above is deleted
if: steps.changed-files-specific.outputs.any_deleted == 'true'
env:
DELETED_FILES: |-
${{ steps.changed-files-specific.outputs.deleted_files }}
DELETED_FILES: ${{ steps.changed-files-specific.outputs.deleted_files }}
run: |
for file in "$DELETED_FILES"; do
echo "$file was deleted"
Expand All @@ -879,8 +893,7 @@ See [inputs](#inputs) for more information.
- name: Run step if all listed files above have been deleted
if: steps.changed-files-specific.outputs.only_deleted == 'true'
env:
DELETED_FILES: |-
${{ steps.changed-files-specific.outputs.deleted_files }}
DELETED_FILES: ${{ steps.changed-files-specific.outputs.deleted_files }}
run: |
for file in "$DELETED_FILES"; do
echo "$file was deleted"
Expand Down Expand Up @@ -992,15 +1005,13 @@ jobs:
id: changed-files-specific
uses: tj-actions/changed-files@v40
with:
safe_output: false
base_sha: ${{ steps.get-base-sha.outputs.base_sha }}
files: .github/**

- name: Run step if any file(s) in the .github folder change
if: steps.changed-files-specific.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: |-
${{ steps.changed-files-specific.outputs.all_changed_files }}
ALL_CHANGED_FILES: ${{ steps.changed-files-specific.outputs.all_changed_files }}
run: |
echo "One or more files in the .github folder has changed."
echo "List all the files that have changed: $ALL_CHANGED_FILES"
Expand All @@ -1026,7 +1037,6 @@ See [inputs](#inputs) for more information.
id: changed-files-for-dir1
uses: tj-actions/changed-files@v40
with:
safe_output: false
path: dir1

- name: List all added files in dir1
Expand Down

0 comments on commit 6e79d6e

Please sign in to comment.