3
0
Fork 0
mirror of https://github.com/tj-actions/changed-files synced 2024-12-16 19:27:39 +00:00
changed-files/action.yml

249 lines
10 KiB
YAML
Raw Normal View History

2022-04-08 09:43:01 +00:00
name: Changed Files
2022-04-08 09:41:00 +00:00
description: Get all Added, Copied, Modified, Deleted, Renamed, Type changed, Unmerged, Unknown files.
2021-03-05 02:36:52 +00:00
author: tj-actions
2021-03-05 02:36:52 +00:00
inputs:
2021-03-05 12:25:17 +00:00
separator:
description: "Split character for output strings"
required: false
2021-03-05 12:25:17 +00:00
default: " "
include_all_old_new_renamed_files:
description: "Include all_old_new_renamed_files output. Note this can generate a large debug output See: #501."
required: false
default: "false"
old_new_separator:
description: "Split character for old and new filename pairs"
required: false
default: ","
old_new_files_separator:
description: "Split character for multiple old and new filename pairs"
required: false
default: " "
files_from_source_file:
description: "Source file(s) 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: ""
files_separator:
description: "Separator used to split the files input"
default: "\n"
required: false
files_ignore:
description: "Ignore changes to this list of files"
required: false
default: ""
files_ignore_separator:
description: "Separator used to split the files-ignore input"
default: "\n"
required: false
files_ignore_from_source_file:
description: "Source file(s) to populate the files-ignore input"
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
since_last_remote_commit:
description: "Use the last commit on the remote branch as the base_sha for push event."
required: false
default: "false"
since:
description: "Get changed files for commits whose timestamp is older than the given time"
required: false
default: ""
until:
description: "Get changed files for commits whose timestamp is earlier than the given time"
required: false
default: ""
path:
description: "Specify a relative path under $GITHUB_WORKSPACE to locate the repository"
required: false
default: "."
quotepath:
description: "Output filenames completely verbatim by setting this to false"
default: "true"
required: false
diff_relative:
description: "Exclude changes outside the current directory and show pathnames relative to it"
required: false
dir_names:
default: "false"
description: "Output the absolute path to the changed directories instead of the filenames"
required: false
json:
description: "Output changed files in JSON format which can be used for matrix jobs"
required: false
default: "false"
2021-03-05 12:25:17 +00:00
2021-03-05 03:43:17 +00:00
outputs:
added_files:
description: List of added files.
value: ${{ steps.changed-files.outputs.added_files }}
2021-03-05 03:43:17 +00:00
copied_files:
description: List of copied files.
value: ${{ steps.changed-files.outputs.copied_files }}
2021-03-05 03:43:17 +00:00
deleted_files:
description: List of deleted files.
value: ${{ steps.changed-files.outputs.deleted_files }}
2021-03-05 03:43:17 +00:00
modified_files:
2021-03-05 11:03:04 +00:00
description: List of modified files.
value: ${{ steps.changed-files.outputs.modified_files }}
2021-03-05 03:43:17 +00:00
renamed_files:
description: List of renamed files.
value: ${{ steps.changed-files.outputs.renamed_files }}
2022-05-14 21:54:38 +00:00
all_old_new_renamed_files:
description: List of all old and new names of renamed files.
value: ${{ steps.changed-files.outputs.all_old_new_renamed_files }}
type_changed_files:
description: List of files that had type changes.
value: ${{ steps.changed-files.outputs.type_changed_files }}
2021-03-05 03:43:17 +00:00
unmerged_files:
description: List of unmerged files.
value: ${{ steps.changed-files.outputs.unmerged_files }}
2021-03-05 03:43:17 +00:00
unknown_files:
description: List of unknown files.
value: ${{ steps.changed-files.outputs.unknown_files }}
all_changed_and_modified_files:
2021-03-05 03:43:17 +00:00
description: List of all changed files.
value: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
all_changed_files:
description: List of all copied, modified, and added files.
value: ${{ steps.changed-files.outputs.all_changed_files }}
2021-05-01 17:32:09 +00:00
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 when all 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 }}
all_modified_files:
description: List of all copied, modified, added and deleted files.
value: ${{ steps.changed-files.outputs.all_modified_files }}
any_modified:
description: Return true only when any files provided using the files input have been modified.
value: ${{ steps.changed-files.outputs.any_modified }}
only_modified:
description: Return true when all files provided using the files input have been modified.
value: ${{ steps.changed-files.outputs.only_modified }}
other_modified_files:
description: Return list of modified files not listed in the files input.
value: ${{ steps.changed-files.outputs.other_modified_files }}
any_deleted:
description: Return true only when any files provided using the files input have been deleted.
value: ${{ steps.changed-files.outputs.any_deleted }}
only_deleted:
description: Return true when all files provided using the files input have been deleted.
value: ${{ steps.changed-files.outputs.only_deleted }}
other_deleted_files:
description: Return list of deleted files not listed in the files input.
value: ${{ steps.changed-files.outputs.other_deleted_files }}
2021-03-05 02:36:52 +00:00
runs:
using: "composite"
steps:
- run: |
# "Set base sha..."
if [[ -n "${{ inputs.since }}" ]]; then
2022-08-21 03:38:24 +00:00
BASE_SHA=$(git log --format="%H" --date=local --since="${{ inputs.since }}" --reverse | head -n 1)
if [[ -z "$BASE_SHA" ]]; then
echo "::warning::The BASE_SHA for date '${{ inputs.since }}' couldn't be determined."
fi
echo "::set-output name=base_sha::$BASE_SHA"
elif [[ -n "${{ inputs.base_sha }}" ]]; then
echo "::set-output name=base_sha::${{ inputs.base_sha }}"
elif [[ "${{ inputs.since_last_remote_commit }}" == "true" ]]; then
2022-09-13 04:04:33 +00:00
LAST_REMOTE_COMMIT="${{ github.event.before }}"
if [[ -z "$LAST_REMOTE_COMMIT" || "$LAST_REMOTE_COMMIT" == "0000000000000000000000000000000000000000" ]]; then
2022-09-13 04:04:33 +00:00
LAST_REMOTE_COMMIT=$(git rev-parse $(git branch -r --sort=-committerdate | head -1))
fi
if [[ "${{ inputs.sha }}" == "$LAST_REMOTE_COMMIT" ]]; then
LAST_REMOTE_COMMIT=$(git rev-parse "${{ inputs.sha }}^1")
fi
echo "::set-output name=base_sha::$LAST_REMOTE_COMMIT"
fi
id: base-sha
shell: bash
- run: |
# "Set the sha..."
if [[ -n "${{ inputs.until }}" ]]; then
2022-08-21 03:24:54 +00:00
SHA=$(git log -1 --format="%H" --date=local --until="${{ inputs.until }}")
if [[ -z "$SHA" ]]; then
echo "::warning::The SHA for date '${{ inputs.until }}' couldn't be determined, falling back to the current sha."
fi
echo "::set-output name=sha::$SHA"
else
2022-08-21 02:29:00 +00:00
echo "::set-output name=sha::${{ inputs.sha }}"
fi
id: sha
shell: bash
- run: |
# "Calculating the previous and current SHA..."
bash $GITHUB_ACTION_PATH/diff-sha.sh
id: changed-files-diff-sha
shell: bash
env:
GITHUB_SERVER_URL: ${{ github.server_url }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_BASE_REF: ${{ github.base_ref }}
GITHUB_HEAD_REF: ${{ github.head_ref }}
GITHUB_ACTION_PATH: ${{ github.action_path }}
GITHUB_WORKSPACE: ${{ github.workspace }}
2022-09-24 04:57:32 +00:00
GITHUB_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
# 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: ${{ steps.sha.outputs.sha }}
INPUT_BASE_SHA: ${{ steps.base-sha.outputs.base_sha }}
INPUT_PATH: ${{ inputs.path }}
Add support for using github's glob pattern syntax (#304) * Add support for using github's glob pattern syntax Fixes: #264 #265 * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update sourcefiles.sh * Update sourcefiles.sh * Update action.yml * Update action.yml * Update action.yml * Update action.yml * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update action.yml * Update test.yml * Update changed-files-list.txt * Update changed-files-list.txt * Update action.yml * Update action.yml * Update entrypoint.sh * Update test.yml * Update README.md * Update test.yml * Update entrypoint.sh * Update test.yml Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-01-05 02:38:03 +00:00
- name: Glob match
2022-08-26 05:25:39 +00:00
uses: tj-actions/glob@v13
Add support for using github's glob pattern syntax (#304) * Add support for using github's glob pattern syntax Fixes: #264 #265 * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update sourcefiles.sh * Update sourcefiles.sh * Update action.yml * Update action.yml * Update action.yml * Update action.yml * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update action.yml * Update test.yml * Update changed-files-list.txt * Update changed-files-list.txt * Update action.yml * Update action.yml * Update entrypoint.sh * Update test.yml * Update README.md * Update test.yml * Update entrypoint.sh * Update test.yml Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-01-05 02:38:03 +00:00
id: glob
with:
files: ${{ inputs.files }}
files-separator: ${{ inputs.files_separator }}
escape-paths: true
excluded-files: ${{ inputs.files_ignore }}
excluded-files-separator: ${{ inputs.files_ignore_separator }}
files-from-source-file: ${{ inputs.files_from_source_file }}
excluded-files-from-source-file: ${{ inputs.files_ignore_from_source_file}}
working-directory: ${{ inputs.path }}
base-sha: ${{ steps.changed-files-diff-sha.outputs.previous_sha }}
sha: ${{ steps.changed-files-diff-sha.outputs.current_sha }}
include-deleted-files: true
separator: "|"
- run: |
bash $GITHUB_ACTION_PATH/entrypoint.sh
id: changed-files
shell: bash
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
GITHUB_WORKSPACE: ${{ github.workspace }}
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
INPUT_FILES_PATTERN_FILE: ${{ steps.glob.outputs.paths-output-file }}
INPUT_SEPARATOR: ${{ inputs.separator }}
INPUT_PATH: ${{ inputs.path }}
INPUT_PREVIOUS_SHA: ${{ steps.changed-files-diff-sha.outputs.previous_sha }}
INPUT_CURRENT_SHA: ${{ steps.changed-files-diff-sha.outputs.current_sha }}
INPUT_TARGET_BRANCH: ${{ steps.changed-files-diff-sha.outputs.target_branch }}
INPUT_CURRENT_BRANCH: ${{ steps.changed-files-diff-sha.outputs.current_branch }}
INPUT_QUOTEPATH: ${{ inputs.quotepath }}
INPUT_INCLUDE_ALL_OLD_NEW_RENAMED_FILES: ${{ inputs.include_all_old_new_renamed_files }}
INPUT_OLD_NEW_SEPARATOR: ${{ inputs.old_new_separator }}
INPUT_OLD_NEW_FILES_SEPARATOR: ${{ inputs.old_new_files_separator }}
INPUT_DIFF_RELATIVE: ${{ inputs.diff_relative }}
INPUT_DIR_NAMES: ${{ inputs.dir_names }}
INPUT_JSON: ${{ inputs.json }}
2021-03-05 10:58:42 +00:00
2021-03-05 02:36:52 +00:00
branding:
2021-04-23 10:55:01 +00:00
icon: file-text
2021-03-05 02:36:52 +00:00
color: white