mirror of
https://github.com/tj-actions/changed-files
synced 2024-12-17 03:47:20 +00:00
feat: add support for writing outputs to files (#890)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
parent
c4bb28b25e
commit
83952deb06
3 changed files with 58 additions and 0 deletions
12
.github/workflows/test.yml
vendored
12
.github/workflows/test.yml
vendored
|
@ -372,6 +372,18 @@ jobs:
|
|||
echo '${{ toJSON(steps.changed-files-since-last-remote-commit.outputs) }}'
|
||||
shell:
|
||||
bash
|
||||
- name: Run changed-files with write_output_files
|
||||
id: changed-files-write-output-files
|
||||
uses: ./
|
||||
with:
|
||||
json: true
|
||||
write_output_files: true
|
||||
- name: Show output
|
||||
run: |
|
||||
echo '${{ toJSON(steps.changed-files-write-output-files.outputs.all_changed_files) }}'
|
||||
cat .github/outputs/all_changed_files.json
|
||||
shell:
|
||||
bash
|
||||
- name: Run changed-files with include_all_old_new_renamed_files
|
||||
id: changed-files-all-old-new-renamed-files
|
||||
uses: ./
|
||||
|
|
38
action.yml
38
action.yml
|
@ -88,6 +88,14 @@ inputs:
|
|||
description: "Use the last commit on the remote branch as the `base_sha`. Defaults to the last non merge commit on the target branch for pull request events and the previous remote commit of the current branch for push events."
|
||||
required: true
|
||||
default: "false"
|
||||
write_output_files:
|
||||
description: "Write outputs to files in the `.github/outputs` folder by default."
|
||||
required: false
|
||||
default: "false"
|
||||
output_dir:
|
||||
description: "Directory to store output files."
|
||||
required: false
|
||||
default: ".github/outputs"
|
||||
|
||||
outputs:
|
||||
added_files:
|
||||
|
@ -230,6 +238,36 @@ runs:
|
|||
INPUT_DIR_NAMES_MAX_DEPTH: ${{ inputs.dir_names_max_depth }}
|
||||
INPUT_JSON: ${{ inputs.json }}
|
||||
INPUT_HAS_CUSTOM_PATTERNS: ${{ steps.glob.outputs.has-custom-patterns }}
|
||||
- name: Generate output files
|
||||
uses: tj-actions/json2file@v1
|
||||
if: inputs.write_output_files == 'true'
|
||||
with:
|
||||
outputs: ${{ toJSON(steps.changed-files.outputs) }}
|
||||
directory: ${{ inputs.output_dir }}
|
||||
skip_missing_keys: true
|
||||
keys: |
|
||||
added_files
|
||||
copied_files
|
||||
deleted_files
|
||||
modified_files
|
||||
renamed_files
|
||||
all_old_new_renamed_files
|
||||
type_changed_files
|
||||
unmerged_files
|
||||
unknown_files
|
||||
all_changed_and_modified_files
|
||||
all_changed_files
|
||||
any_changed
|
||||
only_changed
|
||||
other_changed_files
|
||||
all_modified_files
|
||||
any_modified
|
||||
only_modified
|
||||
other_modified_files
|
||||
any_deleted
|
||||
only_deleted
|
||||
other_deleted_files
|
||||
extension: ${{ steps.changed-files.outputs.outputs_extension }}
|
||||
|
||||
branding:
|
||||
icon: file-text
|
||||
|
|
|
@ -10,6 +10,12 @@ INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\r'/'%0D'}"
|
|||
GITHUB_OUTPUT=${GITHUB_OUTPUT:-""}
|
||||
DIFF=$INPUT_DIFF
|
||||
|
||||
OUTPUTS_EXTENSION="txt"
|
||||
|
||||
if [[ "$INPUT_JSON" == "true" ]]; then
|
||||
OUTPUTS_EXTENSION="json"
|
||||
fi
|
||||
|
||||
if [[ $INPUT_QUOTEPATH == "false" ]]; then
|
||||
git config --global core.quotepath off
|
||||
else
|
||||
|
@ -403,6 +409,7 @@ if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|||
echo "::set-output name=all_changed_and_modified_files::$ALL_CHANGED_AND_MODIFIED"
|
||||
echo "::set-output name=all_changed_files::$ALL_CHANGED"
|
||||
echo "::set-output name=all_modified_files::$ALL_MODIFIED"
|
||||
echo "::set-output name=outputs_extension::$OUTPUTS_EXTENSION"
|
||||
else
|
||||
cat <<EOF >>"$GITHUB_OUTPUT"
|
||||
added_files=$ADDED
|
||||
|
@ -416,6 +423,7 @@ unknown_files=$UNKNOWN
|
|||
all_changed_and_modified_files=$ALL_CHANGED_AND_MODIFIED
|
||||
all_changed_files=$ALL_CHANGED
|
||||
all_modified_files=$ALL_MODIFIED
|
||||
outputs_extension=$OUTPUTS_EXTENSION
|
||||
EOF
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue