From 180763a87d1ef1c44c73f6555ed172b969761c25 Mon Sep 17 00:00:00 2001 From: Bert Goethals Date: Thu, 28 Jan 2021 20:10:31 +0100 Subject: [PATCH] Provide bare action implementation --- action.yml | 23 +++++++++++++++++++++++ entrypoint.sh | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 action.yml create mode 100755 entrypoint.sh diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..c3c7692 --- /dev/null +++ b/action.yml @@ -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 diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..b69dc63 --- /dev/null +++ b/entrypoint.sh @@ -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