Last active
October 24, 2022 01:50
-
-
Save alismx/1c13dca8dc96ed4947f016aae19aacff to your computer and use it in GitHub Desktop.
GitHub action and workflow to set swap space. It feels hacky. Use it if you are running into memory issues on large builds.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Set Swap Space' | |
description: Used to set swap | |
inputs: | |
swap-size-gb: | |
description: 'Swap space to create, in Gigabytes.' | |
required: false | |
default: '10' | |
runs: | |
using: "composite" | |
steps: | |
- name: Swap space report before modification | |
shell: bash | |
run: | | |
echo "Memory and swap:" | |
free -h | |
echo | |
swapon --show | |
echo | |
- name: Set Swap | |
shell: bash | |
run: | | |
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 | |
- name: Swap space report after modification | |
shell: bash | |
run: | | |
echo "Memory and swap:" | |
free -h | |
echo | |
swapon --show | |
echo | |
# use in workflow | |
# - name: Set Swap Space | |
# uses: ./.github/actions/set-swap-space | |
# with: | |
# swap-size-gb: 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment