Skip to content

Build and publish imswitch images #11

Build and publish imswitch images

Build and publish imswitch images #11

Workflow file for this run

name: Build and publish imswitch images
permissions:
contents: write
on:
release:
types: [published]
workflow_dispatch:
jobs:
build-imswitch-image:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Add imswitch Stage
run: |
mkdir -p stage-imswitch/package-imswitch
# Create depends file so pi-gen knows this stage depends on stage2
echo "2" > stage-imswitch/depends
cat > stage-imswitch/package-imswitch/00-run-chroot.sh << 'EOF'
#!/bin/bash -e
# --------------------------------------------------------------------
# 1. Stop services from auto-starting in chroot
# --------------------------------------------------------------------
cat << 'POLICYRC' > /usr/sbin/policy-rc.d
#!/bin/sh
exit 101
POLICYRC
chmod +x /usr/sbin/policy-rc.d
# --------------------------------------------------------------------
# 2. Fix hostname resolution warnings (sudo: unable to resolve host ...)
# --------------------------------------------------------------------
echo "127.0.0.1 $(hostname)" >> /etc/hosts
# --------------------------------------------------------------------
# 3. Ensure non-interactive debconf
# --------------------------------------------------------------------
export DEBIAN_FRONTEND=noninteractive
# --------------------------------------------------------------------
# 4. Install dependencies (pip3, git, nano, etc.)
# --------------------------------------------------------------------
apt-get update && apt-get install -y git nano python3-pip
# --------------------------------------------------------------------
# 5. Clone and run the install script
# --------------------------------------------------------------------
git clone https://github.com/openUC2/ImSwitchDockerInstall
cd ImSwitchDockerInstall
chmod +x install_native.sh
./install_native.sh
# --------------------------------------------------------------------
# 6. Remove policy-rc.d so final system can start services on boot
# --------------------------------------------------------------------
rm /usr/sbin/policy-rc.d
exit 0
EOF
chmod +x stage-imswitch/package-imswitch/00-run-chroot.sh
cat > stage-imswitch/prerun.sh << 'EOF'
#!/bin/bash -e
if [ ! -d "${ROOTFS_DIR}" ]; then
copy_previous
fi
EOF
chmod +x stage-imswitch/prerun.sh
- name: Build imswitch Image
id: build
uses: usimd/pi-gen-action@v1
with:
enable-ssh: 1
stage-list: stage0 stage1 stage2 ./stage-imswitch
verbose-output: true
image-name: imswitch-raspi-lite
# Basic config
disable-first-boot-user-rename: 0
enable-noobs: false
hostname: uc2
password: youseetoo
keyboard-layout: de
timezone: Europe/Berlin
locale: en_US.UTF-8
# If your scripts need e.g. parted or other build-host packages, add them here
extra-host-dependencies: git nano
wpa-country: DE
wpa-essid: "Blynk"
wpa-password: "12345678"
# If you see memory errors:
increase-runner-disk-size: true
- name: Upload Artifact
uses: svenstaro/upload-release-action@v2
with:
asset_name: "imswitch-bookworm.img.zip"
file: ${{ steps.build.outputs.image-path }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.event.inputs.tag || github.ref }}
overwrite: true