Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #644 from tj-actions/feat/make-since-last-remote-t…
…he-default
- Loading branch information
Showing
6 changed files
with
101 additions
and
52 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
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
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
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,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
if [[ -n $INPUT_PATH ]]; then | ||
REPO_DIR="$GITHUB_WORKSPACE/$INPUT_PATH" | ||
|
||
echo "Resolving repository path: $REPO_DIR" | ||
if [[ ! -d "$REPO_DIR" ]]; then | ||
echo "::error::Invalid repository path: $REPO_DIR" | ||
exit 1 | ||
fi | ||
cd "$REPO_DIR" | ||
fi | ||
|
||
if [[ -n "$INPUT_SINCE" ]]; then | ||
BASE_SHA=$(git log --format="%H" --date=local --since="$INPUT_SINCE" --reverse | head -n 1) | ||
if [[ -z "$BASE_SHA" ]]; then | ||
echo "::warning::The BASE_SHA for date '$INPUT_SINCE' couldn't be determined." | ||
fi | ||
echo "::set-output name=base_sha::$BASE_SHA" | ||
elif [[ -n "$INPUT_BASE_SHA" ]]; then | ||
echo "::set-output name=base_sha::$INPUT_BASE_SHA" | ||
elif [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "true" ]]; then | ||
LAST_REMOTE_COMMIT="$GITHUB_EVENT_BEFORE" | ||
|
||
if [[ -z "$LAST_REMOTE_COMMIT" || "$LAST_REMOTE_COMMIT" == "0000000000000000000000000000000000000000" ]]; then | ||
LAST_REMOTE_COMMIT=$(git rev-parse "$(git branch -r --sort=-committerdate | head -1)") | ||
fi | ||
if [[ "$INPUT_SHA" == "$LAST_REMOTE_COMMIT" ]]; then | ||
LAST_REMOTE_COMMIT=$(git rev-parse "$INPUT_SHA^1") | ||
fi | ||
echo "::set-output name=base_sha::$LAST_REMOTE_COMMIT" | ||
fi |
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
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,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
if [[ -n $INPUT_PATH ]]; then | ||
REPO_DIR="$GITHUB_WORKSPACE/$INPUT_PATH" | ||
|
||
echo "Resolving repository path: $REPO_DIR" | ||
if [[ ! -d "$REPO_DIR" ]]; then | ||
echo "::error::Invalid repository path: $REPO_DIR" | ||
exit 1 | ||
fi | ||
cd "$REPO_DIR" | ||
fi | ||
|
||
if [[ -n "$INPUT_UNTIL" ]]; then | ||
SHA=$(git log -1 --format="%H" --date=local --until="$INPUT_UNTIL") | ||
if [[ -z "$SHA" ]]; then | ||
echo "::warning::The SHA for date '$INPUT_UNTIL' couldn't be determined, falling back to the current sha." | ||
fi | ||
echo "::set-output name=sha::$SHA" | ||
else | ||
echo "::set-output name=sha::$INPUT_SHA" | ||
fi |