From 8a5f6280e652c097c5f12e2cfb145cf5f1b7cff9 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sun, 25 Dec 2022 23:51:17 -0700 Subject: [PATCH] chore: update the default sha (#896) --- action.yml | 2 +- diff-sha.sh | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index 3e19148d3a0..98884136dd1 100644 --- a/action.yml +++ b/action.yml @@ -46,7 +46,6 @@ inputs: sha: description: "Specify a different commit SHA used for comparing changes" required: false - default: ${{ github.sha }} base_sha: description: "Specify a different base commit SHA used for comparing changes" required: false @@ -174,6 +173,7 @@ runs: GITHUB_SERVER_URL: ${{ github.server_url }} GITHUB_REPOSITORY: ${{ github.repository }} GITHUB_REF: ${{ github.ref }} + GITHUB_SHA: ${{ github.sha }} GITHUB_BASE_REF: ${{ github.base_ref }} GITHUB_HEAD_REF: ${{ github.head_ref }} GITHUB_WORKSPACE: ${{ github.workspace }} diff --git a/diff-sha.sh b/diff-sha.sh index efe250978f0..ef02928e56d 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -54,6 +54,11 @@ if [[ -z $GITHUB_BASE_REF ]]; then echo "Running on a push event..." TARGET_BRANCH=$GITHUB_REFNAME CURRENT_BRANCH=$TARGET_BRANCH + + echo "Fetching remote refs..." + + # shellcheck disable=SC2086 + git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH" 1>/dev/null 2>&1 echo "::debug::Getting HEAD SHA..." if [[ -n "$INPUT_UNTIL" ]]; then @@ -68,8 +73,6 @@ if [[ -z $GITHUB_BASE_REF ]]; then if [[ -z $INPUT_SHA ]]; then CURRENT_SHA=$(git rev-list -n 1 HEAD) && exit_status=$? || exit_status=$? else - # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH" 1>/dev/null 2>&1 CURRENT_SHA=$INPUT_SHA; exit_status=$? fi fi @@ -131,8 +134,6 @@ if [[ -z $GITHUB_BASE_REF ]]; then fi fi else - # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH" 1>/dev/null 2>&1 PREVIOUS_SHA=$INPUT_BASE_SHA fi @@ -174,10 +175,6 @@ else CURRENT_SHA=$(git rev-list -n 1 HEAD) && exit_status=$? || exit_status=$? else CURRENT_SHA=$INPUT_SHA; exit_status=$? - - if [[ "$CURRENT_SHA" == "$GITHUB_EVENT_PULL_REQUEST_HEAD_SHA" ]]; then - CURRENT_SHA=$(git rev-list -n 1 HEAD) && exit_status=$? || exit_status=$? - fi fi fi