Skip to content

Commit

Permalink
Add disk space to OS image on CI to avoid running out of space (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcapona authored Sep 13, 2024
1 parent f9215e0 commit 412e1e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/create-usb-setup-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,25 @@ jobs:
unzip pi-topOS.zip
- name: Mount OS Image root partition
uses: jcapona/mount-image-partition-action@v0.3
uses: jcapona/mount-image-partition-action@v1.0
with:
imagePath: ${{ env.IMAGE_FILE }}
mountPoint: ${{ env.MOUNT_POINT }}
partitionIndex: 3
filesystem: ext4
partitionIndex: 4
extraDiskSpace: 1024

- name: Update pi-topOS container and download packages
run: |
sudo systemd-nspawn --pipe --bind "$PWD":/packages -D "${{ env.MOUNT_POINT }}" /bin/bash << EOF
# Update system and download packages
apt update
DEBIAN_FRONTEND=noninteractive apt dist-upgrade -y
cd /packages
ls -lh
bash ./download-packages.sh "${{ matrix.PACKAGES_FOLDER_NAME }}" "${{ matrix.COMPRESSED_UPDATES_FILENAME }}"
# Cleanup
apt-get clean
EOF
- name: Delete OS image to save space
Expand Down
8 changes: 6 additions & 2 deletions download-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ download_package() {
CMD_OUTPUT=$(eval "${DOWNLOAD_CMD}")
# Retry on failure
if [ $? -ne 0 ]; then
echo "Failed to download package ${package}. Retrying with latest version..."
echo "Failed to download package ${package}. Retrying ..."
sleep 1

DOWNLOAD_CMD="apt download ${package_name} &>/dev/null"
# Retry a few times before giving up
for i in {1..10}; do
# After a few attempts, try to download the latest version
if [ $i -eq 7 ]; then
DOWNLOAD_CMD="apt download ${package_name} &>/dev/null"
echo "Failed to download package ${package}. Retrying with latest version..."
fi
CMD_OUTPUT=$(eval "${DOWNLOAD_CMD}")
echo "Downloading ${package_name}, retry ${i}..."
if [ $? -eq 0 ]; then
Expand Down

0 comments on commit 412e1e7

Please sign in to comment.