6767 type : boolean
6868 default : false
6969 fetch-depth :
70- description : Number of commits to fetch (0 for full history)
70+ description : Number of commits to fetch (0 for full history, empty for auto-detect )
7171 required : false
72- type : number
73- default : 1
72+ type : string
73+ default : ' '
74+ cache-name :
75+ description : Name for cache restore (restores {name}.gz with key {name}-)
76+ required : false
77+ type : string
78+ default : ' '
7479
7580jobs :
7681 bazel :
@@ -85,11 +90,33 @@ jobs:
8590 NUGET_API_KEY : ${{ secrets.NUGET_API_KEY }}
8691 NODE_AUTH_TOKEN : ${{ secrets.NODE_AUTH_TOKEN }}
8792 steps :
93+ - name : Calculate fetch depth
94+ id : depth
95+ shell : bash
96+ env :
97+ FETCH_DEPTH : ${{ inputs.fetch-depth }}
98+ PR_COMMITS : ${{ github.event.pull_request.commits }}
99+ run : |
100+ # Use explicit value if provided
101+ if [ -n "$FETCH_DEPTH" ]; then
102+ echo "val=$FETCH_DEPTH" >> "$GITHUB_OUTPUT"
103+ # For PRs, use commit count plus buffer for merge base
104+ elif [ -n "$PR_COMMITS" ]; then
105+ echo "val=$((PR_COMMITS + 2))" >> "$GITHUB_OUTPUT"
106+ # For push events, read commit count from event payload
107+ else
108+ COMMIT_COUNT=$(jq -e '.commits | length // 0' "$GITHUB_EVENT_PATH" 2>/dev/null) || COMMIT_COUNT=0
109+ echo "val=$((COMMIT_COUNT + 1))" >> "$GITHUB_OUTPUT"
110+ fi
88111 - name : Checkout source tree
89112 uses : actions/checkout@v4
90113 with :
91114 ref : ${{ inputs.ref || github.ref }}
92- fetch-depth : ${{ inputs.fetch-depth }}
115+ fetch-depth : ${{ steps.depth.outputs.val }}
116+ fetch-tags : ${{ inputs.fetch-depth != '' }}
117+ - name : Fetch base ref for PR comparison
118+ if : github.event.pull_request.base.sha
119+ run : git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }}
93120 - name : Pull latest changes from head ref for PRs
94121 if : contains(github.head_ref, 'renovate/')
95122 run : git pull origin "$HEAD_REF"
@@ -100,9 +127,13 @@ jobs:
100127 run : git pull origin "$GIT_REF"
101128 env :
102129 GIT_REF : ${{ github.ref }}
103- - name : Free space
104- if : inputs.os != 'windows'
105- run : ./scripts/github-actions/free-disk-space.sh
130+ - name : Restore cache
131+ if : inputs.cache-name != ''
132+ uses : actions/cache/restore@v4
133+ with :
134+ path : ${{ inputs.cache-name }}
135+ key : ${{ inputs.cache-name }}-
136+ restore-keys : ${{ inputs.cache-name }}-
106137 - name : Remove driver directories Windows
107138 if : inputs.os == 'windows'
108139 run : |
@@ -225,7 +256,7 @@ jobs:
225256 limit-access-to-actor : false
226257 - name : Save git diff
227258 if : always() && inputs.artifact-name != '' && inputs.artifact-path == ''
228- run : git diff --binary > changes.patch
259+ run : git add -A && git diff --binary --staged > changes.patch
229260 - name : Upload artifact
230261 if : always() && inputs.artifact-name != ''
231262 uses : actions/upload-artifact@v5
@@ -234,3 +265,13 @@ jobs:
234265 path : ${{ inputs.artifact-path || 'changes.patch' }}
235266 retention-days : 6
236267 if-no-files-found : ${{ inputs.artifact-path != '' && 'error' || 'warn' }}
268+ - name : Check disk space
269+ if : always()
270+ shell : bash
271+ run : |
272+ avail=$(df -k "$GITHUB_WORKSPACE" | awk 'NR==2 {printf "%.0f", $4/1024/1024}')
273+ echo "Remaining disk space: ${avail}GB"
274+ if [ "$avail" -lt 5 ]; then
275+ echo "::error::Low disk space: ${avail}GB remaining"
276+ exit 1
277+ fi
0 commit comments