-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Detect path Changes | ||
inputs: | ||
base_branch: | ||
description: "Branch to compare with" | ||
required: false | ||
default: ${{ github.event.repository.default_branch }} | ||
pathspec: | ||
description: "Pattern used to limit paths in the `git diff-tree` command." | ||
required: false | ||
default: "" | ||
outputs: | ||
changed: | ||
description: "Whether or not files matched by the pathspec were changed." | ||
value: ${{ steps.run.outputs.changed }} | ||
fork_point_sha: | ||
description: "The sha we compared with" | ||
value: ${{ steps.run.outputs.fork_point_sha }} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- id: run | ||
run: ${{ github.action_path }}/entrypoint.sh ${{ inputs.base_branch }} ${{ inputs.pathspec }} | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
BASE_BRANCH="remotes/origin/$1" | ||
PATHSPEC=$2 | ||
FORK_POINT_SHA=$(git merge-base --fork-point $BASE_BRANCH) | ||
|
||
echo ::set-output name=fork_point_sha::$FORK_POINT_SHA | ||
|
||
function check() { | ||
|
||
if [[ -z "$(git diff --name-only $FORK_POINT_SHA $PATHSPEC)" ]]; | ||
then | ||
echo "Detected no changes on $PATHSPEC since $FORK_POINT_SHA" | ||
echo ::set-output name=changed::false | ||
else | ||
echo "Detected changes on $PATHSPEC since $FORK_POINT_SHA" | ||
echo ::set-output name=changed::true | ||
fi | ||
} | ||
|
||
check |