3
0
Fork 0
mirror of https://github.com/tj-actions/changed-files synced 2024-12-17 23:44:46 +00:00
changed-files/get-sha.sh
2022-10-12 11:35:06 -05:00

24 lines
610 B
Bash

#!/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 "sha=$SHA" >>"$GITHUB_OUTPUT"
else
echo "sha=$INPUT_SHA" >>"$GITHUB_OUTPUT"
fi