Skip to content

Commit

Permalink
Provide bare action implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertg committed Jan 28, 2021
1 parent c172833 commit 180763a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
23 changes: 23 additions & 0 deletions action.yml
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
22 changes: 22 additions & 0 deletions entrypoint.sh
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

0 comments on commit 180763a

Please sign in to comment.