Skip to content

Commit ad4357d

Browse files
committed
use pr head ref and not the merge ref
1 parent 645499e commit ad4357d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,16 @@ jobs:
135135
GITHUB_TOKEN: ${{ github.token }}
136136
EXCLUDE_COMMIT: ${{ github.event.after }}
137137
run: python3 -u ci_changes_per_commit.py
138+
- name: Set head sha
139+
if: github.event_name == 'pull_request'
140+
run: echo "HEAD_SHA=$(git show -s --format=%s $GITHUB_SHA | grep -o -P "(?<=Merge ).*(?= into)")" >> $GITHUB_ENV
138141
- name: Set base sha
139142
if: github.event_name == 'pull_request'
140143
run: |
141-
DEEPEN=$((DEPTH - $(git rev-list HEAD --count))) && if((DEEPEN > 0)); then git fetch --no-tags --recurse-submodules=no --deepen=$DEEPEN; fi
142-
echo "BASE_SHA=$(git rev-list $GITHUB_SHA --skip=$((DEPTH + 1)) --max-count=1)" >> $GITHUB_ENV
144+
git fetch --no-tags --no-recurse-submodules --depth=$((DEPTH + 1)) origin $HEAD_SHA
145+
echo "BASE_SHA=$(git rev-list $HEAD_SHA --skip=$DEPTH --max-count=1)" >> $GITHUB_ENV
143146
env:
144147
DEPTH: ${{ steps.get-last-commit-with-checks.outputs.commit_depth || github.event.pull_request.commits }}
145-
- name: Set head sha
146-
if: github.event_name == 'pull_request'
147-
run: echo "HEAD_SHA=$(git rev-list $GITHUB_SHA --skip=1 --max-count=1)" >> $GITHUB_ENV
148148
- name: Get changes
149149
id: get-changes
150150
if: github.event_name == 'pull_request'

0 commit comments

Comments
 (0)