excatract gz #54
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: Archlinux aarch64 Raspberry Pi Image Builder | |
on: [push] | |
jobs: | |
build-image: | |
name: Build Archlinux aarch64 Raspberry Pi Image | |
env: | |
INSTALL_REQUIREMENTS: false | |
LOOP_IMAGE: archlinux-aarch64-rpi.img | |
LOOP_IMAGE_SIZE: 4G | |
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
RPI_MODEL: 5 | |
ARM_VERSION: aarch64 | |
runs-on: self-hosted | |
environment: main | |
# container: archlinux:latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Generate Dynamic Variables | |
run: | | |
echo "RPI_HOSTNAME=sz-arch-${{ env.ARM_VERSION }}-rpi${{ env.RPI_MODEL }}" >> $GITHUB_ENV | |
echo "WORKDIR_BASE=${{ github.workspace }}/run-${{ github.run_id }}" >> $GITHUB_ENV | |
echo "LOOP_IMAGE_PATH=${{ github.workspace }}/run-${{ github.run_id }}/sz-arch-${{ env.ARM_VERSION }}-rpi${{ env.RPI_MODEL }}.img" >> $GITHUB_ENV | |
echo "DISTRO=$(cat /etc/*-release | grep ^ID= | cut -d'=' -f2)" >> $GITHUB_ENV | |
echo "ARCH_AARCH64_IMG_URL=http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-${{ env.ARM_VERSION }}-latest.tar.gz" >> $GITHUB_ENV | |
echo "ARCH_AARCH64_IMG_URL_MD5=http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-${{ env.ARM_VERSION }}-latest.tar.gz.md5" >> $GITHUB_ENV | |
- name: Display All Environment Variables | |
run: | | |
printenv | |
- name: Update system and install dependencies for Arch Linux | |
if: env.INSTALL_REQUIREMENTS == 'true' && env.DISTRO == 'arch' | |
run: | | |
sudo pacman -Syu --noconfirm | |
sudo pacman -S --noconfirm qemu-user-static-binfmt qemu-user-static dosfstools wget libarchive sudo arch-install-scripts | |
- name: Update system and install dependencies for Ubuntu | |
if: env.INSTALL_REQUIREMENTS == 'true' && env.DISTRO == 'ubuntu' | |
run: | | |
sudo apt update | |
sudo apt-get install -y arch-install-scripts qemu-user-static binfmt-support dosfstools wget libarchive-tools sudo | |
- name: Create Work Folder and apply permissions | |
run: | | |
sudo mkdir -p $WORKDIR_BASE | |
sudo chown -R $USER:$USER $WORKDIR_BASE | |
echo "Created $WORKDIR_BASE and applied permissions" | |
- name: Create Image File | |
run: | | |
fallocate -l $LOOP_IMAGE_SIZE $LOOP_IMAGE_PATH | |
- name: Download Archlinux aarch64 Image | |
run: | | |
cd $WORKDIR_BASE | |
wget -q $ARCH_AARCH64_IMG_URL -O $WORKDIR_BASE/ArchLinuxARM-rpi-${{ env.ARM_VERSION }}-latest.tar.gz | |
wget -q $ARCH_AARCH64_IMG_URL_MD5 -O $WORKDIR_BASE/ArchLinuxARM-rpi-${{ env.ARM_VERSION }}-latest.tar.gz.md5 | |
md5sum -c $WORKDIR_BASE/ArchLinuxARM-rpi-${{ env.ARM_VERSION }}-latest.tar.gz.md5 | |
- name: Setup Loop Device | |
run: | | |
sudo losetup -fP $LOOP_IMAGE_PATH | |
LOOP_DEVICE=$(sudo losetup -j $LOOP_IMAGE_PATH | cut -d: -f1) | |
echo "Loop device is $LOOP_DEVICE" | |
echo "LOOP_DEVICE=$LOOP_DEVICE" >> $GITHUB_ENV | |
- name: Create Partitions | |
run: | | |
sudo parted --script $LOOP_DEVICE mklabel msdos | |
sudo parted --script $LOOP_DEVICE mkpart primary fat32 1MiB 257MiB | |
sudo parted --script $LOOP_DEVICE mkpart primary ext4 257MiB 100% | |
sudo parted --script $LOOP_DEVICE set 1 boot on | |
sudo parted --script $LOOP_DEVICE print | |
- name: Format Partitions | |
run: | | |
sudo mkfs.vfat -F32 ${LOOP_DEVICE}p1 -n PI-BOOT | |
sudo mkfs.ext4 -q -E lazy_itable_init=0,lazy_journal_init=0 -F ${LOOP_DEVICE}p2 -L PI-ROOT | |
- name: Mount Partitions | |
run: | | |
sudo mkdir -p $WORKDIR_BASE/root | |
sudo mount ${LOOP_DEVICE}p2 $WORKDIR_BASE/root | |
sudo mkdir -p $WORKDIR_BASE/root/boot | |
sudo mount ${LOOP_DEVICE}p1 $WORKDIR_BASE/root/boot | |
- name: Extract Archlinux aarch64 Image | |
run: | | |
sudo bsdtar -xpf $WORKDIR_BASE/ArchLinuxARM-rpi-${{ env.ARM_VERSION }}-latest.tar.gz -C $WORKDIR_BASE/root | |
sudo sync | |
- name: Run Build Script | |
run: | | |
sudo chmod +x ./build-archlinux-rpi-aarch64-img.sh | |
sudo ./build-archlinux-rpi-aarch64-img.sh | |
# - name: Upload Image and Get URL | |
# if: success() | |
# run: | | |
# ISO_URL=$(curl --upload-file $LOOP_IMAGE_PATH https://pub.strat.zone/) | |
# echo "ISO_URL=$ISO_URL" >> $GITHUB_ENV | |
# - name: Notify Success | |
# if: success() | |
# run: | | |
# SUCCESS_MESSAGE="🎉 Awesome! The Raspberry Pi image build succeeded 🚀\nAuthor: ${{ github.actor }}\nBranch: ${{ github.ref }}\nCommit Message: ${{ github.event.head_commit.message }}\n[View Last Commit](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) 📜\nThe custom-built Archlinux image for Raspberry Pi Model ${{ env.RPI_MODEL }} with ${{ env.ARM_VERSION }} architecture is now available for download:\n[Download Image]($ISO_URL) 📦\nFilename: archlinux-${{ env.ARM_VERSION }}-rpi-${{ env.RPI_MODEL }}.img" | |
# curl -X POST -H "Content-Type: application/json" -d "{\"content\": \"$SUCCESS_MESSAGE\"}" $DISCORD_WEBHOOK_URL | |
# - name: Notify Failure | |
# if: failure() | |
# run: | | |
# FAILURE_MESSAGE="😞 Oops! The pipeline for **${{ github.repository }}** has failed.\n[Check the logs and troubleshoot here.](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) 🛠️" | |
# curl -X POST -H "Content-Type: application/json" -d "{\"content\": \"$FAILURE_MESSAGE\"}" $DISCORD_WEBHOOK_URL | |
# - name: Umount Loop Device | |
# if: always() | |
# run: | | |
# sudo umount -R $WORKDIR_BASE || true | |
# echo "Unmounted $WORKDIR_BASE" | |
# - name: Delete Work Folder | |
# if: always() | |
# run: | | |
# sudo rm -rf $WORKDIR_BASE | |
# echo "Work folder deleted" | |
# - name: Release Loop Device | |
# if: always() | |
# run: | | |
# if [ -n "$LOOP_DEVICE" ]; then | |
# sudo losetup -d $LOOP_DEVICE | |
# echo "Loop device $LOOP_DEVICE released" | |
# fi |