mirror of
https://github.com/tj-actions/changed-files
synced 2024-12-17 13:47:20 +00:00
86 lines
3.5 KiB
YAML
86 lines
3.5 KiB
YAML
name: Get modified files
|
|
description: Get modified files
|
|
author: tj-actions
|
|
inputs:
|
|
token:
|
|
description: 'GITHUB_TOKEN or a Repo scoped PAT'
|
|
required: true
|
|
default: ${{ github.token }}
|
|
|
|
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 }}
|
|
changed_files:
|
|
description: List of changed files.
|
|
value: ${{ steps.changed-files.outputs.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 }}
|
|
|
|
runs:
|
|
using: 'composite'
|
|
steps:
|
|
- id: changed-files
|
|
run: |
|
|
if [[ -z $GITHUB_BASE_REF ]]; then
|
|
echo "Skipping: This should only run on pull_request.";
|
|
exit 0;
|
|
fi
|
|
|
|
TARGET_BRANCH=${GITHUB_BASE_REF}
|
|
CURRENT_BRANCH=${GITHUB_HEAD_REF}
|
|
|
|
echo "Getting base branch..."
|
|
git config --local remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
|
git config --local --add remote.origin.fetch "+refs/tags/*:refs/tags/*"
|
|
|
|
git fetch --depth=1 origin ${TARGET_BRANCH}:${TARGET_BRANCH}
|
|
|
|
echo "Getting head sha..."
|
|
|
|
HEAD_SHA=$(git rev-parse ${TARGET_BRANCH} || true)
|
|
|
|
read -a ADDED_FILES <<< "$(git diff --diff-filter=A --name-only ${HEAD_SHA} || true)"
|
|
read -a COPIED_FILES <<< "$(git diff --diff-filter=C --name-only ${HEAD_SHA} || true)"
|
|
read -a DELETED_FILES <<< "$(git diff --diff-filter=D --name-only ${HEAD_SHA} || true)"
|
|
read -a MODIFIED_FILES <<< "$(git diff --diff-filter=M --name-only ${HEAD_SHA} || true)"
|
|
read -a RENAMED_FILES <<< "$(git diff --diff-filter=R --name-only ${HEAD_SHA} || true)"
|
|
read -a CHANGED_FILES <<< "$(git diff --diff-filter=T --name-only ${HEAD_SHA} || true)"
|
|
read -a UNMERGED_FILES <<< "$(git diff --diff-filter=U --name-only ${HEAD_SHA} || true)"
|
|
read -a UNKNOWN_FILES <<< "$(git diff --diff-filter=X --name-only ${HEAD_SHA} || true)"
|
|
read -a ALL_CHANGED_FILES <<< "$(git diff --diff-filter='*' --name-only ${HEAD_SHA} || true)"
|
|
|
|
echo "Getting diff..."
|
|
echo "::set-output name=added_files::${{ toJSON($ADDED_FILES) }}"
|
|
echo "::set-output name=copied_files::${{ toJSON($COPIED_FILES) }}"
|
|
echo "::set-output name=deleted_files::${{ toJSON($DELETED_FILES) }}"
|
|
echo "::set-output name=modified_files::${{ toJSON($MODIFIED_FILES) }}"
|
|
echo "::set-output name=renamed_files::${{ toJSON($RENAMED_FILES) }}"
|
|
echo "::set-output name=changed_files::${{ toJSON($CHANGED_FILES) }}"
|
|
echo "::set-output name=unmerged_files::${{ toJSON($UNMERGED_FILES) }}"
|
|
echo "::set-output name=unknown_files::${{ toJSON($UNKNOWN_FILES) }}"
|
|
echo "::set-output name=all_changed_files::${{ toJSON($ALL_CHANGED_FILES) }}"
|
|
shell: bash
|
|
|
|
branding:
|
|
icon: git-pull-request
|
|
color: white
|