Merge pull request #21 from tj-actions/add-support-for-push-events
This commit is contained in:
commit
7b1f7ad57b
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@ -1,6 +1,9 @@
|
|||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
42
action.yml
42
action.yml
@ -10,53 +10,51 @@ inputs:
|
|||||||
outputs:
|
outputs:
|
||||||
added_files:
|
added_files:
|
||||||
description: List of added files.
|
description: List of added files.
|
||||||
value: ${{ steps.changed-files.outputs.added_files }}
|
value: ${{ steps.changed_files.outputs.added_files }}
|
||||||
copied_files:
|
copied_files:
|
||||||
description: List of copied files.
|
description: List of copied files.
|
||||||
value: ${{ steps.changed-files.outputs.copied_files }}
|
value: ${{ steps.changed_files.outputs.copied_files }}
|
||||||
deleted_files:
|
deleted_files:
|
||||||
description: List of deleted files.
|
description: List of deleted files.
|
||||||
value: ${{ steps.changed-files.outputs.deleted_files }}
|
value: ${{ steps.changed_files.outputs.deleted_files }}
|
||||||
modified_files:
|
modified_files:
|
||||||
description: List of modified files.
|
description: List of modified files.
|
||||||
value: ${{ steps.changed-files.outputs.modified_files }}
|
value: ${{ steps.changed_files.outputs.modified_files }}
|
||||||
renamed_files:
|
renamed_files:
|
||||||
description: List of renamed files.
|
description: List of renamed files.
|
||||||
value: ${{ steps.changed-files.outputs.renamed_files }}
|
value: ${{ steps.changed_files.outputs.renamed_files }}
|
||||||
changed_files:
|
changed_files:
|
||||||
description: List of changed files.
|
description: List of changed files.
|
||||||
value: ${{ steps.changed-files.outputs.changed_files }}
|
value: ${{ steps.changed_files.outputs.changed_files }}
|
||||||
unmerged_files:
|
unmerged_files:
|
||||||
description: List of unmerged files.
|
description: List of unmerged files.
|
||||||
value: ${{ steps.changed-files.outputs.unmerged_files }}
|
value: ${{ steps.changed_files.outputs.unmerged_files }}
|
||||||
unknown_files:
|
unknown_files:
|
||||||
description: List of unknown files.
|
description: List of unknown files.
|
||||||
value: ${{ steps.changed-files.outputs.unknown_files }}
|
value: ${{ steps.changed_files.outputs.unknown_files }}
|
||||||
all_changed_files:
|
all_changed_files:
|
||||||
description: List of all changed files.
|
description: List of all changed files.
|
||||||
value: ${{ steps.changed-files.outputs.all_changed_files }}
|
value: ${{ steps.changed_files.outputs.all_changed_files }}
|
||||||
all_modified_files:
|
all_modified_files:
|
||||||
description: List of all copied modified and added files
|
description: List of all copied modified and added files
|
||||||
value: ${{ steps.changed-files.outputs.all_modified_files }}
|
value: ${{ steps.changed_files.outputs.all_modified_files }}
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
steps:
|
steps:
|
||||||
- id: changed-files
|
- id: changed_files
|
||||||
run: |
|
run: |
|
||||||
if [[ -z $GITHUB_BASE_REF ]]; then
|
|
||||||
echo "Skipping: This should only run on pull_request.";
|
|
||||||
exit 0;
|
|
||||||
fi
|
|
||||||
|
|
||||||
TARGET_BRANCH=${GITHUB_BASE_REF}
|
|
||||||
|
|
||||||
git fetch --depth=1 origin ${TARGET_BRANCH}:${TARGET_BRANCH}
|
|
||||||
|
|
||||||
echo "Getting head sha..."
|
echo "Getting head sha..."
|
||||||
|
|
||||||
|
if [[ -z $GITHUB_BASE_REF ]]; then
|
||||||
|
HEAD_SHA=$(git rev-parse HEAD^1 || true)
|
||||||
|
else
|
||||||
|
TARGET_BRANCH=${GITHUB_BASE_REF}
|
||||||
|
git fetch --depth=1 origin ${TARGET_BRANCH}:${TARGET_BRANCH}
|
||||||
HEAD_SHA=$(git rev-parse ${TARGET_BRANCH} || true)
|
HEAD_SHA=$(git rev-parse ${TARGET_BRANCH} || true)
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Getting diff..."
|
||||||
ADDED=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
ADDED=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
||||||
COPIED=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
COPIED=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
||||||
DELETED=$(git diff --diff-filter=D --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
DELETED=$(git diff --diff-filter=D --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
||||||
@ -68,7 +66,7 @@ runs:
|
|||||||
ALL_CHANGED=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
ALL_CHANGED=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
||||||
ALL_MODIFIED_FILES=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
ALL_MODIFIED_FILES=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//')
|
||||||
|
|
||||||
echo "Getting diff..."
|
|
||||||
echo "::set-output name=added_files::$ADDED"
|
echo "::set-output name=added_files::$ADDED"
|
||||||
echo "::set-output name=copied_files::$COPIED"
|
echo "::set-output name=copied_files::$COPIED"
|
||||||
echo "::set-output name=deleted_files::$DELETED"
|
echo "::set-output name=deleted_files::$DELETED"
|
||||||
@ -82,5 +80,5 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
icon: git-pull-request
|
icon: git-commit
|
||||||
color: white
|
color: white
|
||||||
|
Loading…
x
Reference in New Issue
Block a user