diff --git a/.github/workflows/sync-release-version.yml b/.github/workflows/sync-release-version.yml index 127c444a9c8..463810e0901 100644 --- a/.github/workflows/sync-release-version.yml +++ b/.github/workflows/sync-release-version.yml @@ -1,8 +1,5 @@ name: Update release version. on: - push: - tags: - - '**' release: types: [published] diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c641ea12233..c09fa4fcb0d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,6 +27,8 @@ jobs: uses: actions/checkout@v3 - name: shellcheck uses: reviewdog/action-shellcheck@v1.15 + with: + github_token: ${{ secrets.PAT_TOKEN }} test-multiple-repositories: name: Test with multiple repositories @@ -929,7 +931,7 @@ jobs: with: branch: ${{ steps.branch-name.outputs.base_ref_branch }} workflow_id: 'test.yml' - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ secrets.PAT_TOKEN }} - name: Run changed-files with a custom base sha if: github.event_name == 'pull_request' && github.event.action != 'closed' id: changed-files-custom-base-sha diff --git a/diff-sha.sh b/diff-sha.sh index e6de07d1851..3cdd64ef38c 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -187,11 +187,8 @@ else PREVIOUS_SHA=$GITHUB_EVENT_BEFORE if ! git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1; then - PREVIOUS_SHA=$(git rev-list -n 1 "$TARGET_BRANCH" 2>&1) && exit_status=$? || exit_status=$? - fi - - if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "0000000000000000000000000000000000000000" ]]; then - PREVIOUS_SHA=$(git rev-list -n 1 "$TARGET_BRANCH" 2>&1) && exit_status=$? || exit_status=$? + # shellcheck disable=SC2046 + PREVIOUS_SHA=$(git rev-parse $(git branch -r --sort=-committerdate | head -1) 2>&1) && exit_status=$? || exit_status=$? fi else PREVIOUS_SHA=$(git rev-list -n 1 "$TARGET_BRANCH" 2>&1) && exit_status=$? || exit_status=$? @@ -214,16 +211,18 @@ else depth=$INPUT_FETCH_DEPTH max_depth=$INPUT_MAX_FETCH_DEPTH - while [ -z "$( git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA" )" ] || [ -z "$(git merge-base "$TARGET_BRANCH" "$CURRENT_SHA")" ] || [ -z "$(git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA"..."$CURRENT_SHA" | head -1)" ]; do - depth=$((depth + 300)) + while ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA"..."$CURRENT_SHA" 1>/dev/null; do + echo "Fetching $depth commits..." # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS --deepen="$depth" origin "$TARGET_BRANCH" HEAD; + git fetch $EXTRA_ARGS --deepen="$depth" origin "$TARGET_BRANCH" "$CURRENT_SHA"; if [[ $depth -gt $max_depth ]]; then - echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and HEAD" + echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_SHA" exit 1 fi + + depth=$((depth + 300)) done else echo "::debug::Not a shallow clone, skipping merge-base check."