From abd84c54a35272c2ff5480c73ab96670447352b1 Mon Sep 17 00:00:00 2001 From: David Zager Date: Thu, 4 Apr 2024 14:45:08 -0400 Subject: [PATCH] :seedling: flag to use swap when building images Signed-off-by: David Zager --- .github/workflows/build-push-images.yaml | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/build-push-images.yaml b/.github/workflows/build-push-images.yaml index 37a8183..944fcac 100644 --- a/.github/workflows/build-push-images.yaml +++ b/.github/workflows/build-push-images.yaml @@ -34,6 +34,11 @@ on: default: "." required: false type: string + swap-size-gb: + description: 'Swap space to create, in Gigabytes.' + default: "" + required: false + type: string secrets: registry_username: description: "Quay publish robot" @@ -52,6 +57,27 @@ jobs: matrix: architecture: ${{ fromJSON(inputs.architectures) }} steps: + - name: Get more swap space + shell: bash + if: "${{ inputs.swap-size-gb != '' }}" + run: | + echo "Before swap" + free -h + swapon --show + + # Make swap + export SWAP_FILE=$(swapon --show=NAME | tail -n 1) + sudo swapoff $SWAP_FILE + sudo rm $SWAP_FILE + sudo fallocate -l ${{ inputs.swap-size-gb }}G $SWAP_FILE + sudo chmod 600 $SWAP_FILE + sudo mkswap $SWAP_FILE + sudo swapon $SWAP_FILE + + echo "After swap" + free -h + swapon --show + - name: Maximize disk space shell: bash run: |