Skip to content

Commit 1bae2ca

Browse files
authored
Check for disk space only once (#14331)
* Check for disk space only once * Set 80% as limit * Fix running of binaries
1 parent 96e9d29 commit 1bae2ca

File tree

1 file changed

+43
-23
lines changed

1 file changed

+43
-23
lines changed

.github/workflows/binaries.yml

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,41 @@ jobs:
128128
echo "🚫 Label 'dev: binaries' not found – skipping upload"
129129
fi
130130
131+
disk-space-check:
132+
needs: conditions
133+
runs-on: ubuntu-latest
134+
outputs:
135+
available: ${{ steps.diskspace.outputs.available }}
136+
steps:
137+
- name: No upload
138+
if: needs.conditions.outputs.upload-to-builds-jabref-org == 'false'
139+
shell: bash
140+
run: |
141+
echo "available=false" >> "$GITHUB_OUTPUT"
142+
echo "🚫 no upload – skipping upload"
143+
- name: Setup SSH key
144+
if: needs.conditions.outputs.upload-to-builds-jabref-org == 'true'
145+
run: |
146+
echo "${{ secrets.buildJabRefPrivateKey }}" > sshkey
147+
chmod 600 sshkey
148+
- name: Check disk space on builds.jabref.org
149+
if: needs.conditions.outputs.upload-to-builds-jabref-org == 'true'
150+
shell: bash
151+
run: |
152+
USAGE=$(ssh -p 9922 -i sshkey -o StrictHostKeyChecking=no [email protected] \
153+
"df --output=pcent /var/www/builds.jabref.org | tail -n1 | tr -dc '0-9'")
154+
echo "Remote usage: ${USAGE}%"
155+
156+
if [ "$USAGE" -lt 80 ]; then
157+
echo "available=true" >> "$GITHUB_OUTPUT"
158+
echo "☁️ enough disk space available – will upload"
159+
else
160+
echo "available=false" >> "$GITHUB_OUTPUT"
161+
echo "🚫 not enough disk space – skipping upload"
162+
fi
163+
131164
build:
132-
needs: [conditions]
165+
needs: [conditions, disk-space-check]
133166
if: ${{ needs.conditions.outputs.should-build == 'true' }}
134167
strategy:
135168
fail-fast: false
@@ -281,62 +314,49 @@ jobs:
281314
282315
# region Upload to builds.jabref.org / GitHub artifacts store
283316
- name: Setup SSH key
284-
if: (needs.conditions.outputs.upload-to-builds-jabref-org == 'true')
317+
if: ${{ needs.disk-space-check.available == 'true' }}
285318
run: |
286319
echo "${{ secrets.buildJabRefPrivateKey }}" > sshkey
287320
chmod 600 sshkey
288-
- name: Check disk space on builds.jabref.org
289-
if: (needs.conditions.outputs.upload-to-builds-jabref-org == 'true')
290-
id: diskspace
291-
shell: bash
292-
run: |
293-
USAGE=$(ssh -p 9922 -i sshkey -o StrictHostKeyChecking=no [email protected] \
294-
"df --output=pcent /var/www/builds.jabref.org | tail -n1 | tr -dc '0-9'")
295-
echo "Remote usage: $USAGE%"
296-
if [ "$USAGE" -lt 90 ]; then
297-
echo "available=true" >> "$GITHUB_OUTPUT"
298-
else
299-
echo "available=false" >> "$GITHUB_OUTPUT"
300-
fi
301321
- name: Setup rsync (macOS)
302-
if: ${{ (steps.diskspace.outputs.available == 'true') && (startsWith(matrix.os, 'macos') && (needs.conditions.outputs.upload-to-builds-jabref-org == 'true')) }}
322+
if: ${{ (needs.disk-space-check.available == 'true') && (startsWith(matrix.os, 'macos') && (needs.conditions.outputs.upload-to-builds-jabref-org == 'true')) }}
303323
run: brew install rsync
304324
- name: Setup rsync (Windows)
305-
if: ${{ (steps.diskspace.outputs.available == 'true') && (matrix.os == 'windows-latest') }}
325+
if: ${{ (needs.disk-space-check.available == 'true') && (matrix.os == 'windows-latest') }}
306326
# We want to have rsync available at this place to avoid uploading and downloading from GitHub artifact store (taking > 5 minutes in total)
307327
# We cannot use "action-rsyncer", because that requires Docker which is unavailable on Windows
308328
# We cannot use "setup-rsync", because that does not work on Windows
309329
# We do not use egor-tensin/setup-cygwin@v4, because it replaces the default shell
310330
# We need to use v6.4.4 as v6.4.5 misses "lib\rsync\tools\bin\ssh.exe"
311331
run: choco install rsync --version=6.4.4
312332
- name: Upload jabgui to builds.jabref.org (Windows)
313-
if: ${{ (steps.diskspace.outputs.available == 'true') && (matrix.os == 'windows-latest') }}
333+
if: ${{ (needs.disk-space-check.available == 'true') && (matrix.os == 'windows-latest') }}
314334
shell: cmd
315335
# for rsync installed by chocolatey, we need the ssh.exe delivered with that installation
316336
run: |
317337
rsync -rt --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r --itemize-changes --stats --rsync-path="mkdir -p /var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }} && rsync" -e 'C:\ProgramData\chocolatey\lib\rsync\tools\bin\ssh.exe -p 9922 -i sshkey -o StrictHostKeyChecking=no' jabgui/build/packages/${{ matrix.os }}/ [email protected]:/var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }}/ || true
318338
- name: Upload jabkkit to builds.jabref.org (Windows)
319-
if: ${{ (steps.diskspace.outputs.available == 'true') && (matrix.os == 'windows-latest') }}
339+
if: ${{ (needs.disk-space-check.available == 'true') && (matrix.os == 'windows-latest') }}
320340
shell: cmd
321341
run: |
322342
rsync -rt --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r --itemize-changes --stats --rsync-path="mkdir -p /var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }} && rsync" -e 'C:\ProgramData\chocolatey\lib\rsync\tools\bin\ssh.exe -p 9922 -i sshkey -o StrictHostKeyChecking=no' jabkit/build/packages/${{ matrix.os }}/ [email protected]:/var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }}/ || true
323343
- name: Upload jabls-cli to builds.jabref.org (Windows)
324-
if: ${{ (steps.diskspace.outputs.available == 'true') && (matrix.os == 'windows-latest') }}
344+
if: ${{ (needs.disk-space-check.available == 'true') && (matrix.os == 'windows-latest') }}
325345
shell: cmd
326346
run: |
327347
rsync -rt --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r --itemize-changes --stats --rsync-path="mkdir -p /var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }} && rsync" -e 'C:\ProgramData\chocolatey\lib\rsync\tools\bin\ssh.exe -p 9922 -i sshkey -o StrictHostKeyChecking=no' jabls-cli/build/packages/${{ matrix.os }}/ [email protected]:/var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }}/ || true
328348
- name: Upload jabgui to builds.jabref.org (linux, macOS)
329-
if: ${{ (steps.diskspace.outputs.available == 'true') && ((startsWith(matrix.os, 'macos') && (needs.conditions.outputs.should-notarize != 'true')) || startsWith(matrix.os, 'ubuntu')) }}
349+
if: ${{ (needs.disk-space-check.available == 'true') && ((startsWith(matrix.os, 'macos') && (needs.conditions.outputs.should-notarize != 'true')) || startsWith(matrix.os, 'ubuntu')) }}
330350
shell: bash
331351
run: |
332352
rsync -rt --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r --itemize-changes --stats --rsync-path="mkdir -p /var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }} && rsync" -e 'ssh -p 9922 -i sshkey -o StrictHostKeyChecking=no' jabgui/build/packages/${{ matrix.os }}/ [email protected]:/var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }}/ || true
333353
- name: Upload jabkit to builds.jabref.org (linux, macOS)
334-
if: ${{ (steps.diskspace.outputs.available == 'true') && (startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')) }}
354+
if: ${{ (needs.disk-space-check.available == 'true') && (startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')) }}
335355
shell: bash
336356
run: |
337357
rsync -rt --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r --itemize-changes --stats --rsync-path="mkdir -p /var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }} && rsync" -e 'ssh -p 9922 -i sshkey -o StrictHostKeyChecking=no' jabkit/build/packages/${{ matrix.os }}/ [email protected]:/var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }}/ || true
338358
- name: Upload jabls-cli to builds.jabref.org (linux, macOS)
339-
if: ${{ (steps.diskspace.outputs.available == 'true') && (startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')) }}
359+
if: ${{ (needs.disk-space-check.available == 'true') && (startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')) }}
340360
shell: bash
341361
run: |
342362
rsync -rt --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r --itemize-changes --stats --rsync-path="mkdir -p /var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }} && rsync" -e 'ssh -p 9922 -i sshkey -o StrictHostKeyChecking=no' jabls-cli/build/packages/${{ matrix.os }}/ [email protected]:/var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }}/ || true

0 commit comments

Comments
 (0)