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

67 lines
2.4 KiB
YAML
Raw Normal View History

2021-03-05 02:36:52 +00:00
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 }}
2021-03-05 03:43:17 +00:00
outputs:
added_files:
description: List of added files.
copied_files:
description: List of copied files.
deleted_files:
description: List of deleted files.
modified_files:
description: List of modified files
renamed_files:
description: List of renamed files.
changed_files:
description: List of changed files
unmerged_files:
description: List of unmerged files.
unknown_files:
description: List of unknown files.
all_changed_files:
description: List of all changed files.
2021-03-05 02:36:52 +00:00
runs:
2021-03-05 03:50:33 +00:00
using: 'composite'
steps:
- id: changed-files
run: |
2021-03-05 10:55:53 +00:00
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)
echo "Getting diff..."
echo "::set-output name=added_files::$(git diff --diff-filter=A --name-only ${HEAD_SHA} || true)"
echo "::set-output name=copied_files::$(git diff --diff-filter=C --name-only ${HEAD_SHA} || true)"
echo "::set-output name=deleted_files::$(git diff --diff-filter=D --name-only ${HEAD_SHA} || true)"
echo "::set-output name=modified_files::$(git diff --diff-filter=M --name-only ${HEAD_SHA} || true)"
echo "::set-output name=renamed_files::$(git diff --diff-filter=R --name-only ${HEAD_SHA} || true)"
echo "::set-output name=changed_files::$(git diff --diff-filter=T --name-only ${HEAD_SHA} || true)"
echo "::set-output name=unmerged_files::$(git diff --diff-filter=R --name-only ${HEAD_SHA} || true)"
echo "::set-output name=unknown_files::$(git diff --diff-filter=X --name-only ${HEAD_SHA} || true)"
echo "::set-output name=all_changed_files::$(git diff --diff-filter="*" --name-only ${HEAD_SHA} || true)"
2021-03-05 03:50:33 +00:00
shell: bash
2021-03-05 10:58:42 +00:00
2021-03-05 02:36:52 +00:00
branding:
icon: git-pull-request
color: white