This repository has been archived by the owner on Dec 5, 2024. It is now read-only.
Build Surveillance System OS #53
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: "Build Surveillance System OS" | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
permissions: | |
contents: write | |
pull-requests: read | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Get current date | |
id: date | |
run: echo "stamp=$(date '+%s')" >> $GITHUB_ENV | |
- name: Install tools | |
run: sudo apt update ; sudo apt -y install python-is-python3 python3-pip exfatprogs parted exfat-fuse binfmt-support qemu-user-static | |
- name: Create installer.bin | |
run: truncate -s 16384M installer.bin | |
- name: Create loopback device | |
run: sudo mknod -m 0660 /dev/loop254 b 7 254 | |
- name: Mount installer.bin as loopback device | |
run: sudo losetup -P /dev/loop254 installer.bin | |
- name: Create GPT disk label | |
run: sudo parted /dev/loop254 mklabel gpt | |
- name: Create BOOT partition | |
run: sudo parted /dev/loop254 mkpart primary fat32 1 256 | |
- name: Create SYSTEM partition | |
run: sudo parted /dev/loop254 mkpart primary ext2 256 4096 | |
- name: Create HOME partition | |
run: sudo parted /dev/loop254 mkpart primary fat32 4096 16384 | |
- name: Toogle boot flag on boot partition | |
run: sudo parted /dev/loop254 set 1 boot on | |
- name: Create BOOT filesystem | |
run: sudo mkfs.vfat -F32 /dev/loop254p1 | |
- name: Create SYSTEM filesystem | |
run: sudo mkfs.btrfs /dev/loop254p2 | |
- name: Create HOME filesystem | |
run: sudo mkfs.exfat /dev/loop254p3 | |
- name: Mount SYSTEM filesystem | |
run: sudo mount /dev/loop254p2 /mnt/ | |
- name: Mount BOOT filesystem | |
run: sudo mkdir -p /mnt/boot && sudo mount /dev/loop254p1 /mnt/boot | |
- name: Mount HOME filesystem | |
run: sudo mkdir -p /mnt/home/pi && sudo mount.exfat-fuse /dev/loop254p3 /mnt/home/pi | |
- name: Docker builder | |
run: docker create --name debian-builder arm64v8/debian:stable | |
- name: Add QEMU static | |
run: docker cp /usr/bin/qemu-aarch64-static debian-builder:/usr/bin/qemu-aarch64-static | |
- name: Commit builder | |
run: docker commit debian-builder arm64v8/debian:stable | |
- name: Docker build | |
run: docker build -t surv:latest . | |
- name: Create docker image instance | |
run: docker create --name rpi-image surv:latest | |
- name: Docker export | |
run: cd /mnt ; sudo docker export rpi-image | sudo tar --exclude=etc/machine-id --exclude=etc/*_key* -xf - | |
- name: Home directories | |
run: sudo mkdir /mnt/home/pi/ssh /mnt/home/pi/motion_cam /mnt/home/pi/motion_logs /mnt/home/pi/motion_video /mnt/home/pi/motion_cameras | |
- name: authorized_keys empty file | |
run: sudo touch /mnt/home/pi/ssh/authorized_keys | |
- name: Create empty machine-id | |
run: sudo touch /mnt/etc/machine-id | |
- name: Copy hosts file | |
run: sudo cp hosts /mnt/etc | |
- name: Copy hostname file | |
run: sudo cp hostname /mnt/etc | |
- name: Unmount | |
run: sudo sync && sudo sync && sudo umount /mnt/boot && sudo umount /mnt/home/pi && sudo umount /mnt | |
- name: Disconnect installer.bin | |
run: sudo losetup -D /dev/loop254 | |
- name: Move into directory | |
run: mkdir surveillance_system_os && mv installer.* surveillance_system_os/ | |
- name: Archive directory | |
run: sudo zip -r surveillance_system_os-${{ env.stamp }}.zip surveillance_system_os/ | |
- name: Create GH release | |
uses: actions/create-release@v1 | |
id: create_release | |
with: | |
draft: true | |
prerelease: false | |
release_name: surveillance_system_os-${{ env.stamp }} | |
tag_name: ${{ env.stamp }} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Upload zipped image to release artifacts | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: surveillance_system_os-${{ env.stamp }}.zip | |
asset_name: surveillance_system_os-${{ env.stamp }}.zip | |
asset_content_type: application/zip |