From e33f13105588a252d45b251ec4f5392d7e4813c6 Mon Sep 17 00:00:00 2001 From: Gabriel Y C Chan Date: Mon, 19 Jun 2023 22:51:30 +0800 Subject: [PATCH] integrate with pi-gen. --- .github/workflows/deb.yml | 2 +- .github/workflows/image.yml | 167 ++++++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/image.yml diff --git a/.github/workflows/deb.yml b/.github/workflows/deb.yml index a4e6fe6..124e4fc 100644 --- a/.github/workflows/deb.yml +++ b/.github/workflows/deb.yml @@ -4,7 +4,7 @@ on: push: branches: - master - - ci + # - ci jobs: build: diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml new file mode 100644 index 0000000..a658e18 --- /dev/null +++ b/.github/workflows/image.yml @@ -0,0 +1,167 @@ +name: image + +on: + push: + branches: + - master + - ci + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - name: Check out repository + uses: actions/checkout@v2 + + # download and install hackman package + - run: | + touch stage3/SKIP stage4/SKIP stage5/SKIP + touch stage4/SKIP_IMAGES stage5/SKIP_IMAGES + + mkdir -p stage2a/01-install-hackman/ + cp stage2/EXPORT_IMAGE stage2a/EXPORT_IMAGE + cp stage2/EXPORT_NOOBS stage2a/EXPORT_NOOBS + cp stage2/prerun.sh stage2a/prerun.sh + + cat > stage2a/01-install-hackman/00-packages <<-EOF + redis-server + nginx + libffi-dev + libpq-dev + postgresql + postgresql-contrib + EOF + + cat > stage2a/01-install-hackman/01-run.sh <<-EOF + #!/bin/bash -e + on_chroot << \EOF + curl -sLO https://github.com/dimsumlabs/hackman/releases/download/2306190757-ci/hackman_0.1.0-2306190757-ci_armhf.deb + dpkg -i hackman*.deb + \EOF + EOF + + chmod +x stage2a/01-install-hackman/01-run.sh + chmod +x stage2a/prerun.sh + + - name: Build image + uses: usimd/pi-gen-action@v1 + with: + # Compression to apply on final image (either "none", "zip", "xz" or "gz"). + compression: zip + + # Compression level to be used. From 0 to 9 (refer to the tool man page for more + # information on this. Usually 0 is no compression but very fast, up to 9 with the + # best compression but very slow). + compression-level: 6 + + # Disable the renaming of the first user during the first boot. This make it so + # 'username' stays activated. 'username' must be set for this to work. Please be + # aware of the implied security risk of defining a default username and password + # for your devices. + disable-first-boot-user-rename: 1 + + # Additional options to include in PIGEN_DOCKER_OPTS + docker-opts: '' + + # Set whether a NOOBS image should be built as well. If enabled, the output + # directory containing the NOOBS files will be saved as output variable + # 'image-noobs-path'. + enable-noobs: false + + # Enable SSH access to Pi. + enable-ssh: 1 + + # If this feature is enabled, the action will configure pi-gen to not export any + # stage as image but the last one defined in property 'stage-list'. This is + # helpful when building a single image flavor (in contrast to building a + # lite/server and full-blown desktop image), since it speeds up the build process + # significantly. + export-last-stage-only: true + + # Comma or whitespace separated list of additional packages to install on host + # before running pi-gen. Use this list to add any packages your custom stages may + # require. Note that this is not affecting the final image. In order to add + # additional packages, you need to add a respective 'XX-packages' file in your + # custom stage. + extra-host-dependencies: '' + + # Comma or whitespace separated list of additional modules to load on host before + # running pi-gen. If your custom stage requires additional software or kernel + # modules to be loaded, add them here. Note that this is not meant to configure + # modules to be loaded in the target image. + extra-host-modules: '' + + # Token to use for checking out pi-gen repo. + github-token: ${{ github.token }} + + # Host name of the image. + hostname: door + + # Final image name. + image-name: "door-$(date -u '+%y%m%d%H%M')-${{steps.extract_branch.outputs.branch}}" + + # Default keyboard keymap. + keyboard-keymap: us + + # Default keyboard layout. + keyboard-layout: English (US) + + # Default locale of the system image. + locale: en_US.UTF-8 + + # Password of the intial user account, locked if empty. + password: 'door' # fixme + + # Path where selected pi-gen ref will be checked out to. If the path does not yet + # exist, it will be created (including its parents). + pi-gen-dir: pi-gen + + # GitHub repository to fetch pi-gen from, must be a fork from RPi-Distro/pi-gen. + pi-gen-repository: RPi-Distro/pi-gen + + # Release version of pi-gen to use. This can both be a branch or tag name known in + # the pi-gen repository. + pi-gen-version: arm64 + + # The release version to build images against. Valid values are jessie, stretch, + # buster, bullseye, and testing. + release: bullseye + + # Setting to `1` will prevent pi-gen from dropping the "capabilities" feature. + # Generating the root filesystem with capabilities enabled and running it from a + # filesystem that does not support capabilities (like NFS) can cause issues. Only + # enable this if you understand what it is. + setfcap: '' + + # List of stage name to execute in given order. Relative and absolute paths to + # custom stage directories are allowed here. Note that by default pi-gen exports + # images in stage2 (lite), stage4 and stage5. You probably want to hook in custom + # stages before one of the exported stages. Otherwise, the action will make sure + # any custom stage will include an image export directive. + stage-list: stage0 stage1 stage2 + + # System timezone. + timezone: Asia/Hong_Kong + + # Use qcow2 images to reduce space and runtime requirements. + use-qcow2: 1 + + # Name of the initial user account. + username: pi + + # Print all output from pi-gen. + verbose-output: true + + # Wifi country code of default network to connect to. + wpa-country: '' + + # SSID of a default wifi network to connect to. + wpa-essid: '' + + # Password of default wifi network to connect to. + wpa-password: '' + + # - uses: actions/upload-artifact@v3 + # with: + # name: pi-gen-image + # path: ${{ steps.build.outputs.image-path }}