Skip to content

Commit aafe1b1

Browse files
authored
Calculate PR branch fetch depth instead of hard-coding to 1000 (#13796)
## Summary & Motivation Based off of actions/checkout#552 We should limit the fetch depth of the PR branch checkout to the bare minimum of what we need. ## How I Tested These Changes Applied script to local repository, made sure that the main branch checkout happened and the PR checkout happened with the calculated fetch depth.
1 parent c059cc6 commit aafe1b1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

.github/workflows/build-docs.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ on:
33
push:
44
branches:
55
- master
6-
- 'release-*'
76
paths:
87
- docs/**
98
pull_request:
@@ -17,10 +16,20 @@ jobs:
1716
deploy:
1817
runs-on: ubuntu-latest
1918
steps:
20-
- name: Checkout PR branch
19+
- name: Checkout
20+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
21+
uses: actions/checkout@v3
22+
23+
- name: 'Get PR fetch depth'
24+
if: ${{ github.event.pull_request }}
25+
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
26+
27+
- name: 'Checkout PR branch'
2128
uses: actions/checkout@v3
29+
if: ${{ github.event.pull_request }}
2230
with:
23-
fetch-depth: 1000
31+
ref: ${{ github.event.pull_request.head.ref }}
32+
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
2433

2534
- name: Get changed docs files
2635
if: ${{ github.event.pull_request }}

0 commit comments

Comments
 (0)