mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-18 07:23:24 +09:00
[CI] (.github/actions, .github/workflows): create swap even when the runner image has none
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
name: Set swap space
|
||||
description: Replace the runner's swap with a swap file of the given size
|
||||
inputs:
|
||||
swap-size-gb:
|
||||
description: Size of the swap file in GiB
|
||||
required: true
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
# Hosted images differ: some ship /swapfile, some ship no swap at all. Turn off whatever is
|
||||
# active, then create the file at the path the image used, or /swapfile when there was none.
|
||||
- shell: bash
|
||||
env:
|
||||
SWAP_SIZE_GB: ${{ inputs.swap-size-gb }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
active="$(swapon --show=NAME --noheadings)"
|
||||
swap_file="$(printf '%s\n' "$active" | grep '^/' | tail -n 1 || true)"
|
||||
swap_file="${swap_file:-/swapfile}"
|
||||
if [ -n "$active" ]; then
|
||||
printf '%s\n' "$active" | xargs -r -n1 sudo swapoff
|
||||
fi
|
||||
sudo rm -f "$swap_file"
|
||||
sudo fallocate -l "${SWAP_SIZE_GB}G" "$swap_file"
|
||||
sudo chmod 600 "$swap_file"
|
||||
sudo mkswap "$swap_file"
|
||||
sudo swapon "$swap_file"
|
||||
free -h
|
||||
swapon --show
|
||||
Reference in New Issue
Block a user