Skip to content

Commit 55e939e

Browse files
Handle new default swapfile path
Newer github runners appears to have the swapfile on a different location compared to before, so we update the scripts to handle this, along with being a bit more verbose for debugging.
1 parent add4fac commit 55e939e

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

action.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,40 @@ inputs:
1515
description: 'Size of the new swap space (in gigabytes)'
1616
required: false
1717
type: number
18-
default: 4
18+
default: 3
1919
swap_location:
2020
description: 'Path to the new swap file'
2121
required: false
22-
default: '/mnt/swapfile'
22+
default: '/swapfile'
2323

2424
runs:
2525
using: "composite"
2626
steps:
27-
- name: Replace the current swap file
28-
if: inputs.swap_size != 4 || inputs.swap_location != '/mnt/swapfile'
27+
- name: Check current memory and swap status
2928
shell: bash
3029
run: |
31-
sudo swapoff /mnt/swapfile
30+
echo "-- Current memory status: --"
31+
sudo free -h
32+
echo
33+
echo "-- Current swapfile info: --"
34+
sudo swapon --show
35+
if [ "$(sudo swapon --show --noheadings | wc -l)" -gt 0 ]; then
36+
echo "CURRENT_SWAPFILE_PATH=$(sudo swapon --show --noheadings | head -n 1 | cut -d' ' -f1)" >> $GITHUB_ENV
37+
else
38+
echo "CURRENT_SWAPFILE_PATH=" >> $GITHUB_ENV
39+
fi
3240
33-
sudo rm -v /mnt/swapfile
41+
- name: Remove current swapfile
42+
if: env.CURRENT_SWAPFILE_PATH != ''
43+
shell: bash
44+
run: |
45+
sudo swapoff "${CURRENT_SWAPFILE_PATH}"
46+
47+
sudo rm -v "${CURRENT_SWAPFILE_PATH}"
3448
49+
- name: Create new swap file
50+
shell: bash
51+
run: |
3552
sudo fallocate -l ${{ inputs.swap_size }}G "${{ inputs.swap_location }}"
3653
3754
sudo chmod 600 "${{ inputs.swap_location }}"
@@ -40,11 +57,13 @@ runs:
4057
4158
sudo swapon "${{ inputs.swap_location }}"
4259
43-
- name: Show current memory and swap status
60+
- name: Show new memory and swap status
4461
shell: bash
4562
run: |
63+
echo "-- New memory status: --"
4664
sudo free -h
4765
echo
66+
echo "-- New swapfile info: --"
4867
sudo swapon --show
4968
5069
- name: Mount a tmpfs over /var/lib/docker

0 commit comments

Comments
 (0)