This repository has been archived by the owner on Dec 5, 2024. It is now read-only.
Build Surveillance System OS #30
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 31950M installer.bin | |
- name: Create installer.bin | |
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: Build base installer image | |
run: sudo chmod +x create-debian-usb-key.sh && sudo ./create-debian-usb-key.sh /dev/loop254 | |
- 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 --ignore-failed-read --ignore-command-error --ignore-zeros --warning=all --exclude=home/* --exclude=home/ -xf - | |
- name: Add configs | |
run: sudo rm /mnt/etc/machine-id ; sudo cp fstab /mnt/etc/ ; sudo cp issue.net /mnt/etc/issue.net ; sudo cp sshd_config /mnt/etc/ssh ; sudo cp 10-eth.network /mnt/etc/systemd/network ; sudo mkdir /mnt/home/pi/motion_cameras ; sudo mkdir /mnt/home/pi/motion_logs ; sudo mkdir /mnt/home/pi/motion_video ; sudo rm /mnt/etc/motion/* ; sudo cp motion.conf /mnt/etc/motion ; sudo mkdir /mnt/home/pi/.ssh ; sudo echo "#" > /mnt/home/pi/.ssh/authorized_keys ; sudo cp hostname /mnt/etc | |
- name: Unmount | |
run: sync ; 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 |