Skip to content

Commit 06a9f66

Browse files
author
Your Name
committed
dind
1 parent 1e534da commit 06a9f66

File tree

2 files changed

+122
-26
lines changed

2 files changed

+122
-26
lines changed

.github/workflows/test-update.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Build & Update with Arduino CLI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build-and-update:
13+
runs-on: ubuntu-22.04
14+
services:
15+
docker:
16+
image: docker:dind
17+
options: --privileged --shm-size=2g
18+
volumes:
19+
- /var/run/docker.sock:/var/run/docker.sock:ro
20+
container:
21+
image: ubuntu:latest
22+
23+
env:
24+
ARCH: amd64
25+
APPCLI_REPO: arduino/arduino-app-cli
26+
ROUTER_REPO: arduino/arduino-router
27+
STABLE_DIR: build/stable
28+
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
36+
- name: Build Docker image (no cache)
37+
run: |
38+
docker build --no-cache -t mock-apt-repo -f test.Dockerfile .
39+
40+
- name: Ensure tools on runner
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install -y jq curl docker.io
44+
45+
- name: Install Task (go-task)
46+
run: |
47+
curl -sL https://taskfile.dev/install.sh | sh -s -- -d -b ./bin
48+
echo "$PWD/bin" >> $GITHUB_PATH
49+
task --version
50+
51+
- name: Prepare folder
52+
run: |
53+
mkdir -p "${STABLE_DIR}"
54+
55+
- name: Checkout
56+
uses: actions/checkout@v4
57+
58+
- name: Ensure curl & mkdir
59+
run: |
60+
sudo apt-get update
61+
sudo apt-get install -y curl
62+
mkdir -p "$STABLE_DIR"
63+
64+
# --- Arduino App CLI (.deb) ---
65+
- name: Download arduino-app-cli .deb (from hard-coded tag page)
66+
run: |
67+
set -euo pipefail
68+
BASE="https://github.com/arduino/arduino-app-cli"
69+
# Use the "expanded_assets" page for the tag to get direct links
70+
PAGE="$BASE/releases/expanded_assets/${TAG}"
71+
REL_URL=$(curl -fsSL "$PAGE" | grep -oE '/arduino/arduino-app-cli/releases/download/'"$TAG"'/[^"]+\.deb' | head -n1)
72+
test -n "$REL_URL"
73+
URL="https://github.com${REL_URL}"
74+
echo "Found asset: $URL"
75+
curl -fL "$URL" -o "$STABLE_DIR/arduino-app-cli_${TAG}.deb"
76+
ls -l "$STABLE_DIR"
77+
78+
# --- Arduino Router (.deb) ---
79+
- name: Download arduino-router .deb (from hard-coded tag page)
80+
run: |
81+
set -euo pipefail
82+
BASE="https://github.com/arduino/arduino-router"
83+
PAGE="$BASE/releases/expanded_assets/${TAG}"
84+
REL_URL=$(curl -fsSL "$PAGE" | grep -oE '/arduino/arduino-router/releases/download/'"$TAG"'/[^"]+\.deb' | head -n1)
85+
test -n "$REL_URL"
86+
URL="https://github.com${REL_URL}"
87+
echo "Found asset: $URL"
88+
curl -fL "$URL" -o "$STABLE_DIR/arduino-router_${TAG}.deb"
89+
ls -l "$STABLE_DIR"
90+
91+
92+
- name: Run mock-apt-repo container
93+
run: |
94+
docker run --rm -d \
95+
--privileged \
96+
--cgroupns=host \
97+
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
98+
-v /var/run/docker.sock:/var/run/docker.sock \
99+
-e DOCKER_HOST=unix:///var/run/docker.sock \
100+
--name apt-test-update \
101+
mock-apt-repo
102+
103+
- name: Verify container is running
104+
run: docker ps

test.Dockerfile

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,38 @@
11
FROM debian:trixie
22

3-
ENV container docker
4-
STOPSIGNAL SIGRTMIN+3
5-
VOLUME ["/sys/fs/cgroup"]
6-
7-
# Install systemd + dependencies
8-
RUN apt update && apt install -y systemd systemd-sysv dbus \
9-
dpkg-dev apt-utils adduser gzip \
10-
&& rm -rf /var/lib/apt/lists/*
11-
12-
# Copy your packages and setup repo (as before)
13-
ARG OLD_PACKAGE_PATH=build/old_package
14-
ARG NEW_PACKAGE_PATH=build
15-
ARG APP_PACKAGE_NAME=arduino-app-cli
16-
ARG ROUTER_PACKAGE_NAME=arduino-router
3+
RUN apt update && \
4+
apt install -y systemd systemd-sysv dbus \
5+
sudo docker.io ca-certificates curl gnupg \
6+
dpkg-dev apt-utils adduser gzip && \
7+
rm -rf /var/lib/apt/lists/*
8+
179
ARG ARCH=arm64
1810

19-
COPY ${OLD_PACKAGE_PATH}/${APP_PACKAGE_NAME}*.deb /tmp/old_app.deb
20-
COPY ${NEW_PACKAGE_PATH}/${APP_PACKAGE_NAME}*.deb /tmp/new_app.deb
21-
COPY ${NEW_PACKAGE_PATH}/${ROUTER_PACKAGE_NAME}*.deb /tmp/new_router.deb
11+
COPY build/stable/arduino-app-cli*.deb /tmp/stable.deb
12+
COPY build/arduino-app-cli*.deb /tmp/unstable.deb
13+
COPY build/stable/arduino-router*.deb /tmp/router.deb
14+
2215

23-
RUN apt update && apt install -y /tmp/old_app.deb /tmp/new_router.deb \
24-
&& rm /tmp/old_app.deb \
16+
RUN apt update && apt install -y /tmp/stable.deb /tmp/router.deb \
17+
&& rm /tmp/stable.deb /tmp/router.deb \
2518
&& mkdir -p /var/www/html/myrepo/dists/trixie/main/binary-${ARCH} \
26-
&& mv /tmp/new_app.deb /var/www/html/myrepo/dists/trixie/main/binary-${ARCH}/ \
27-
&& mv /tmp/new_router.deb /var/www/html/myrepo/dists/trixie/main/binary-${ARCH}/
19+
&& mv /tmp/unstable.deb /var/www/html/myrepo/dists/trixie/main/binary-${ARCH}/
2820

2921
WORKDIR /var/www/html/myrepo
3022
RUN dpkg-scanpackages dists/trixie/main/binary-${ARCH} /dev/null | gzip -9c > dists/trixie/main/binary-${ARCH}/Packages.gz
3123
WORKDIR /
3224

25+
26+
3327
RUN usermod -s /bin/bash arduino || true
3428
RUN mkdir -p /home/arduino && chown -R arduino:arduino /home/arduino
29+
RUN usermod -aG docker arduino
30+
3531

3632

3733
RUN echo "deb [trusted=yes arch=${ARCH}] file:/var/www/html/myrepo trixie main" \
3834
> /etc/apt/sources.list.d/my-mock-repo.list
3935

4036

41-
VOLUME [ "/sys/fs/cgroup" ]
42-
43-
44-
4537
# CMD: systemd must be PID 1
46-
CMD ["/sbin/init"]
38+
CMD ["/sbin/init"]

0 commit comments

Comments
 (0)