Fixed test.
This commit is contained in:
parent
1f907ee3bb
commit
26361016d9
51
action.yml
51
action.yml
@ -147,40 +147,31 @@ runs:
|
|||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- run: |
|
- run: |
|
||||||
# "Set base sha..."
|
# "Calculate the base sha..."
|
||||||
if [[ -n "${{ inputs.since }}" ]]; then
|
bash $GITHUB_ACTION_PATH/get-base-sha.sh
|
||||||
BASE_SHA=$(git log --format="%H" --date=local --since="${{ inputs.since }}" --reverse | head -n 1)
|
|
||||||
if [[ -z "$BASE_SHA" ]]; then
|
|
||||||
echo "::warning::The BASE_SHA for date '${{ inputs.since }}' couldn't be determined."
|
|
||||||
fi
|
|
||||||
echo "::set-output name=base_sha::$BASE_SHA"
|
|
||||||
elif [[ -n "${{ inputs.base_sha }}" ]]; then
|
|
||||||
echo "::set-output name=base_sha::${{ inputs.base_sha }}"
|
|
||||||
else
|
|
||||||
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 [[ "${{ inputs.sha }}" == "$LAST_REMOTE_COMMIT" ]]; then
|
|
||||||
LAST_REMOTE_COMMIT=$(git rev-parse "${{ inputs.sha }}^1")
|
|
||||||
fi
|
|
||||||
echo "::set-output name=base_sha::$LAST_REMOTE_COMMIT"
|
|
||||||
fi
|
|
||||||
id: base-sha
|
id: base-sha
|
||||||
shell: bash
|
shell: bash
|
||||||
|
env:
|
||||||
|
GITHUB_WORKSPACE: ${{ github.workspace }}
|
||||||
|
GITHUB_EVENT_BEFORE: ${{ github.event.before }}
|
||||||
|
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
|
||||||
|
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
|
||||||
|
INPUT_SINCE: ${{ inputs.since }}
|
||||||
|
INPUT_BASE_SHA: ${{ inputs.base_sha }}
|
||||||
|
INPUT_SHA: ${{ inputs.sha }}
|
||||||
|
INPUT_PATH: ${{ inputs.path }}
|
||||||
- run: |
|
- run: |
|
||||||
# "Set the sha..."
|
# "Calculate the sha..."
|
||||||
if [[ -n "${{ inputs.until }}" ]]; then
|
bash $GITHUB_ACTION_PATH/get-sha.sh
|
||||||
SHA=$(git log -1 --format="%H" --date=local --until="${{ inputs.until }}")
|
|
||||||
if [[ -z "$SHA" ]]; then
|
|
||||||
echo "::warning::The SHA for date '${{ inputs.until }}' couldn't be determined, falling back to the current sha."
|
|
||||||
fi
|
|
||||||
echo "::set-output name=sha::$SHA"
|
|
||||||
else
|
|
||||||
echo "::set-output name=sha::${{ inputs.sha }}"
|
|
||||||
fi
|
|
||||||
id: sha
|
id: sha
|
||||||
shell: bash
|
shell: bash
|
||||||
|
env:
|
||||||
|
GITHUB_WORKSPACE: ${{ github.workspace }}
|
||||||
|
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
|
||||||
|
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
|
||||||
|
INPUT_UNTIL: ${{ inputs.until }}
|
||||||
|
INPUT_SHA: ${{ inputs.sha }}
|
||||||
|
INPUT_PATH: ${{ inputs.path }}
|
||||||
- run: |
|
- run: |
|
||||||
# "Calculating the previous and current SHA..."
|
# "Calculating the previous and current SHA..."
|
||||||
bash $GITHUB_ACTION_PATH/diff-sha.sh
|
bash $GITHUB_ACTION_PATH/diff-sha.sh
|
||||||
@ -191,7 +182,6 @@ runs:
|
|||||||
GITHUB_REPOSITORY: ${{ github.repository }}
|
GITHUB_REPOSITORY: ${{ github.repository }}
|
||||||
GITHUB_BASE_REF: ${{ github.base_ref }}
|
GITHUB_BASE_REF: ${{ github.base_ref }}
|
||||||
GITHUB_HEAD_REF: ${{ github.head_ref }}
|
GITHUB_HEAD_REF: ${{ github.head_ref }}
|
||||||
GITHUB_ACTION_PATH: ${{ github.action_path }}
|
|
||||||
GITHUB_WORKSPACE: ${{ github.workspace }}
|
GITHUB_WORKSPACE: ${{ github.workspace }}
|
||||||
GITHUB_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
GITHUB_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||||
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
|
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
|
||||||
@ -220,7 +210,6 @@ runs:
|
|||||||
id: changed-files
|
id: changed-files
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
GITHUB_ACTION_PATH: ${{ github.action_path }}
|
|
||||||
GITHUB_WORKSPACE: ${{ github.workspace }}
|
GITHUB_WORKSPACE: ${{ github.workspace }}
|
||||||
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
|
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
|
||||||
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
|
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
|
||||||
|
34
get-base-sha.sh
Normal file
34
get-base-sha.sh
Normal file
@ -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"
|
||||||
|
else
|
||||||
|
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
|
24
get-sha.sh
Normal file
24
get-sha.sh
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user