Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gh actions workflow for building rpi image #17

Open
wants to merge 15 commits into
base: first-impl
Choose a base branch
from
67 changes: 67 additions & 0 deletions .github/workflows/build_rpi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Dispatched Build and publish RaspAP images

permissions:
contents: write

on:
release:
types: [published]
workflow_dispatch:
pull_request:

jobs:
build-raspap-image:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch: "32-bit"
pi_gen_version: "master"
- arch: "64-bit"
pi_gen_version: "arm64"
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4

# - name: Add RaspAP Stage
# run: |
# mkdir -p stage-raspap/package-raspap &&
# {
# cat > stage-raspap/package-raspap/00-run-chroot.sh <<-EOF
# #!/bin/bash
# apt-get update -y && apt-get install -y curl dhcpcd5 iptables procps
# curl -sL https://install.raspap.com | bash -s -- --yes --openvpn 1 --restapi 1 --adblock 1 --wireguard 1 --tcp-bbr 1 --check 0

# # Set Wi-Fi country to prevent RF kill
# raspi-config nonint do_wifi_country "US"
# EOF
# } &&
# chmod +x stage-raspap/package-raspap/00-run-chroot.sh &&
# {
# cat > stage-raspap/prerun.sh <<-EOF
# #!/bin/bash -e
# if [ ! -d "\${ROOTFS_DIR}" ]; then
# copy_previous
# fi
# EOF
# } &&
# chmod +x stage-raspap/prerun.sh

- name: Build RaspAP Image
id: build
uses: usimd/pi-gen-action@v1
with:
image-name: "raspap-bookworm-${{ matrix.arch == '32-bit' && 'armhf' || 'arm64' }}-lite-${{ github.event.inputs.tag || github.ref_name }}"
enable-ssh: 1
stage-list: stage0 stage1 stage2
# stage-list: stage0 stage1 stage2 ./stage-raspap
verbose-output: true
pi-gen-version: ${{ matrix.pi_gen_version }}
pi-gen-repository: RaspAP/pi-gen

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: rpi-deploy-${{ matrix.arch }}.img.zip
path: ${{ steps.build.outputs.image-path }}
60 changes: 60 additions & 0 deletions stage-custom/package-setup/00-run-chroot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
set -e

mkdir -p /proc /dev /sys /run /tmp

# Install required packages
apt-get update
apt-get install -y python3

# Configure Wi-Fi
mkdir -p /etc/wpa_supplicant

cat << EOF > /etc/wpa_supplicant/wpa_supplicant.conf
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="Your_SSID"
psk="Your_Password"
}
EOF

chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf

# Set up a simple HTTP server
cat << SERVER_EOF > /usr/local/bin/simple-http-server.py
#!/usr/bin/env python3
from http.server import BaseHTTPRequestHandler, HTTPServer

class SimpleHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'text/plain')
self.end_headers()
self.wfile.write(b'Hello from Raspberry Pi!')

if __name__ == '__main__':
server = HTTPServer(('0.0.0.0', 8080), SimpleHandler)
print('Starting server at http://0.0.0.0:8080')
server.serve_forever()
SERVER_EOF
chmod +x /usr/local/bin/simple-http-server.py

# Create and enable a systemd service for the HTTP server
cat << SERVICE_EOF > /etc/systemd/system/simple-http-server.service
[Unit]
Description=Simple HTTP Server
After=network.target

[Service]
ExecStart=/usr/local/bin/simple-http-server.py
Restart=always
User=root

[Install]
WantedBy=multi-user.target
SERVICE_EOF

systemctl enable simple-http-server.service
4 changes: 4 additions & 0 deletions stage-custom/prerun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash -e
if [ ! -d "${ROOTFS_DIR}" ]; then
copy_previous
fi
Loading