Skip to content

Commit f0e7e31

Browse files
committed
refactor how base and head commit are set
- avoid `github.event.after` as it isn't available during initial CI run of the PR
1 parent 7027331 commit f0e7e31

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,27 +135,23 @@ jobs:
135135
GITHUB_TOKEN: ${{ github.token }}
136136
EXCLUDE_COMMIT: ${{ github.event.after }}
137137
run: python3 -u ci_changes_per_commit.py
138-
- name: Deepen and convert depth to sha
139-
id: deepen-and-convert-depth-to-sha
138+
- name: Set base sha
140139
run: |
141140
DEEPEN=$((DEPTH - $(git rev-list HEAD --count))) && if((DEEPEN > 0)); then git fetch --no-tags --recurse-submodules=no --deepen=$DEEPEN; fi
142-
echo "commit=$(git rev-list $GITHUB_SHA --skip=$((DEPTH + 1)) --max-count=1)" >> $GITHUB_OUTPUT
141+
echo "BASE_SHA=$(git rev-list $GITHUB_SHA --skip=$((DEPTH + 1)) --max-count=1)" >> $GITHUB_ENV
143142
env:
144143
DEPTH: ${{ steps.get-last-commit-with-checks.outputs.commit_depth || github.event.pull_request.commits }}
144+
- name: Set head sha
145+
run: echo "HEAD_SHA=$(git rev-list $GITHUB_SHA --skip=1 --max-count=1)" >> $GITHUB_ENV
145146
- name: Get changes
146147
id: get-changes
147148
if: github.event_name == 'pull_request'
148149
run: echo $(git diff $BASE_SHA...$HEAD_SHA --name-only) | echo "changed_files=[\"$(sed "s/ /\", \"/g")\"]" >> $GITHUB_OUTPUT
149-
env:
150-
BASE_SHA: ${{ steps.deepen-and-convert-depth-to-sha.outputs.commit }}
151-
HEAD_SHA: ${{ github.event.after }}
152150
- name: Set matrix
153151
id: set-matrix
154152
working-directory: tools
155153
run: python3 -u ci_set_matrix.py
156154
env:
157-
BASE_SHA: ${{ steps.deepen-and-convert-depth-to-sha.outputs.commit }}
158-
HEAD_SHA: ${{ github.event.after }}
159155
CHANGED_FILES: ${{ steps.get-changes.outputs.changed_files }}
160156
LAST_FAILED_JOBS: ${{ steps.get-last-commit-with-checks.outputs.check_runs }}
161157

0 commit comments

Comments
 (0)