this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add image workflow

+131 -1
+1 -1
.github/workflows/cliff.yaml
··· 2 2 on: 3 3 release: 4 4 types: [published] 5 - branches: [master] 5 + branches: [main] 6 6 permissions: 7 7 contents: write 8 8 env:
+130
.github/workflows/image-generator.yaml
··· 1 + name: Raspberry Pi Camera Setup 2 + 3 + on: 4 + release: 5 + types: [published] 6 + branches: [main] 7 + 8 + jobs: 9 + build: 10 + runs-on: ubuntu-latest 11 + 12 + steps: 13 + - name: Checkout repository 14 + uses: actions/checkout@v3 15 + 16 + - name: Install dependencies 17 + run: | 18 + sudo apt-get update 19 + sudo apt-get install -y wget unzip xz-utils fdisk dosfstools qemu-user-static 20 + 21 + - name: Download Raspberry Pi OS Lite 22 + run: | 23 + wget https://downloads.raspberrypi.org/raspios_lite_armhf_latest -O raspios.zip 24 + unzip raspios.zip 25 + mv *.img raspios.img 26 + 27 + - name: Mount image and setup SSH over USB 28 + run: | 29 + # Create a loop device to interact with the image 30 + LOOP_DEV=$(sudo losetup -f --show raspios.img) 31 + 32 + # Ensure we can see the partitions 33 + sudo partprobe $LOOP_DEV 34 + 35 + # Mount the boot partition 36 + sudo mkdir -p /mnt/boot 37 + sudo mount ${LOOP_DEV}p1 /mnt/boot 38 + 39 + # Configure SSH over USB 40 + echo "dtoverlay=dwc2" | sudo tee -a /mnt/boot/config.txt 41 + sudo sed -i 's/rootwait/rootwait modules-load=dwc2,g_ether/' /mnt/boot/cmdline.txt 42 + sudo touch /mnt/boot/ssh 43 + 44 + # Unmount boot partition 45 + sudo umount /mnt/boot 46 + 47 + # Mount the root filesystem 48 + sudo mkdir -p /mnt/rootfs 49 + sudo mount ${LOOP_DEV}p2 /mnt/rootfs 50 + 51 + # Create inky user and home directory 52 + sudo mkdir -p /mnt/rootfs/home/inky 53 + 54 + # Copy camera script to the image 55 + sudo cp ./src/camera_server.py /mnt/rootfs/home/inky/camera_server.py 56 + 57 + # Setup service 58 + sudo mkdir -p /mnt/rootfs/etc/systemd/system 59 + sudo cp ./src/camera.service /mnt/rootfs/etc/systemd/system/camera.service 60 + 61 + # Create a script to enable the service on first boot 62 + cat << 'EOF' | sudo tee /mnt/rootfs/home/inky/setup.sh 63 + #!/bin/bash 64 + sudo systemctl daemon-reload 65 + sudo systemctl enable camera.service 66 + sudo systemctl start camera.service 67 + EOF 68 + 69 + sudo chmod +x /mnt/rootfs/home/inky/setup.sh 70 + 71 + # Add script to rc.local to run on first boot 72 + sudo sed -i 's@exit 0@/home/inky/setup.sh\nexit 0@' /mnt/rootfs/etc/rc.local 73 + 74 + # Set the hostname to inky 75 + echo "inky" | sudo tee /mnt/rootfs/etc/hostname 76 + sudo sed -i 's/raspberrypi/inky/' /mnt/rootfs/etc/hosts 77 + 78 + # Install required packages using chroot 79 + sudo cp /usr/bin/qemu-arm-static /mnt/rootfs/usr/bin/ 80 + cat << 'EOF' | sudo chroot /mnt/rootfs 81 + # Create inky user 82 + useradd -m -s /bin/bash -G sudo,adm,dialout,cdrom,audio,video,plugdev,games,users,input,netdev,gpio,i2c,spi inky 83 + echo "inky:inkycamera" | chpasswd 84 + 85 + # Set permissions 86 + chown -R inky:inky /home/inky 87 + 88 + # Install required packages 89 + apt-get update 90 + apt-get install -y python3-picamera2 python3-websockets 91 + apt-get clean 92 + EOF 93 + 94 + # Unmount and clean up 95 + sudo umount /mnt/rootfs 96 + sudo losetup -d $LOOP_DEV 97 + 98 + - name: Compress image 99 + run: | 100 + xz -z raspios.img 101 + mv raspios.img.xz raspios-camera-ssh-usb.img.xz 102 + 103 + - name: Upload image as artifact 104 + uses: actions/upload-artifact@v3 105 + with: 106 + name: raspberry-pi-camera-image 107 + path: raspios-camera-ssh-usb.img.xz 108 + 109 + - name: Create Release 110 + if: github.event_name == 'push' && github.ref == 'refs/heads/main' 111 + id: create_release 112 + uses: actions/create-release@v1 113 + env: 114 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 115 + with: 116 + tag_name: v${{ github.run_number }} 117 + release_name: Raspberry Pi Camera Image v${{ github.run_number }} 118 + draft: false 119 + prerelease: false 120 + 121 + - name: Upload Release Asset 122 + if: github.event_name == 'push' && github.ref == 'refs/heads/main' 123 + uses: actions/upload-release-asset@v1 124 + env: 125 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 126 + with: 127 + upload_url: ${{ steps.create_release.outputs.upload_url }} 128 + asset_path: ./raspios-camera-ssh-usb.img.xz 129 + asset_name: raspios-camera-ssh-usb.img.xz 130 + asset_content_type: application/octet-stream