3
0
Fork 0
mirror of https://github.com/tj-actions/changed-files synced 2024-12-17 13:47:20 +00:00
changed-files/action.yml
Ivan Pizhenko 8a41500fbe
Implement path parameter (#168)
* Implement path parameter

* Add test

* Update README.md

* Corrections after code review

* Update action.yml

* Update test.yml

* Do not use realpath

* Update entrypoint.sh

* Update test.yml

Co-authored-by: Ivan Pizhenko <IvanPizhenko@users.noreply.github.com>
Co-authored-by: Tonye Jack <jtonye@ymail.com>
2021-08-27 21:53:03 -04:00

110 lines
3.8 KiB
YAML

name: Changed files
description: Get all changed files for push and pull request events.
author: tj-actions
inputs:
token:
description: 'Github token'
required: true
default: ${{ github.token }}
separator:
description: 'Split character for array output'
required: true
default: " "
files_from_source_file:
description: 'Source file to populate the files input'
required: false
default: ""
files:
description: 'Check for changes using only this list of files (Defaults to the entire repo)'
required: false
default: ""
sha:
description: 'Specify a current commit SHA used for comparing changes'
required: true
default: ${{ github.sha }}
base_sha:
description: 'Specify a base commit SHA on used for comparing changes'
required: false
path:
description: 'Specify a relative path under $GITHUB_WORKSPACE to locate the repository'
required: false
outputs:
added_files:
description: List of added files.
value: ${{ steps.changed-files.outputs.added_files }}
copied_files:
description: List of copied files.
value: ${{ steps.changed-files.outputs.copied_files }}
deleted_files:
description: List of deleted files.
value: ${{ steps.changed-files.outputs.deleted_files }}
modified_files:
description: List of modified files.
value: ${{ steps.changed-files.outputs.modified_files }}
renamed_files:
description: List of renamed files.
value: ${{ steps.changed-files.outputs.renamed_files }}
type_changed_files:
description: List of files that had type changes.
value: ${{ steps.changed-files.outputs.type_changed_files }}
unmerged_files:
description: List of unmerged files.
value: ${{ steps.changed-files.outputs.unmerged_files }}
unknown_files:
description: List of unknown files.
value: ${{ steps.changed-files.outputs.unknown_files }}
all_changed_files:
description: List of all changed files.
value: ${{ steps.changed-files.outputs.all_changed_files }}
all_modified_files:
description: List of all copied modified and added files.
value: ${{ steps.changed-files.outputs.all_modified_files }}
any_changed:
description: Return true only when any files provided using the files input have changed.
value: ${{ steps.changed-files.outputs.any_changed }}
only_changed:
description: Return true only when only files provided using the files input have changed.
value: ${{ steps.changed-files.outputs.only_changed }}
other_changed_files:
description: Return list of changed files not listed in the files input.
value: ${{ steps.changed-files.outputs.other_changed_files }}
runs:
using: 'composite'
steps:
- run: |
FILES=()
if [[ -n $INPUT_FILES_FROM_SOURCE_FILE ]]; then
for file in $INPUT_FILES_FROM_SOURCE_FILE
do
FILES+=$(cat $file | sort -u | tr "\n" " " )
done
fi
echo "::set-output name=files::$FILES"
id: source-input-files
shell: bash
env:
INPUT_FILES: ${{ inputs.files }}
INPUT_FILES_FROM_SOURCE_FILE: ${{ inputs.files_from_source_file }}
- run: |
bash $GITHUB_ACTION_PATH/entrypoint.sh
id: changed-files
shell: bash
env:
GITHUB_BASE_REF: ${{ github.base_ref }}
GITHUB_REPOSITORY: ${{ github.repository }}
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
# https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611
INPUT_SHA: ${{ inputs.sha }}
INPUT_BASE_SHA: ${{ inputs.base_sha }}
INPUT_TOKEN: ${{ inputs.token }}
INPUT_FILES: ${{ join(format('{0} {1}', inputs.files, steps.source-input-files.outputs.files), ' ') }}
INPUT_SEPARATOR: ${{ inputs.separator }}
INPUT_PATH: ${{ inputs.path }}
branding:
icon: file-text
color: white