Skip to content

Commit 3d34e1d

Browse files
author
Your Name
committed
dind
1 parent 1e534da commit 3d34e1d

File tree

2 files changed

+176
-26
lines changed

2 files changed

+176
-26
lines changed

.github/workflows/test-update.yml

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
name: Build & Update with Arduino CLI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- test_package_update
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
build-and-update:
15+
runs-on: ubuntu-22.04
16+
# services:
17+
# docker:
18+
# image: docker:dind
19+
# options: --privileged --shm-size=2g
20+
# volumes:
21+
# - /var/run/docker.sock:/var/run/docker.sock:ro
22+
# container:
23+
# image: ubuntu:latest
24+
25+
env:
26+
ARCH: amd64
27+
APPCLI_REPO: arduino/arduino-app-cli
28+
ROUTER_REPO: arduino/arduino-router
29+
STABLE_DIR: build/stable
30+
# ---- Configure what to fetch ----
31+
# Use a specific tag (with leading v) or leave empty to use the latest stable release.
32+
APPCLI_REPO: arduino/arduino-app-cli
33+
APPCLI_TAG: v0.6.6 # or "" to auto-use latest
34+
APPCLI_REGEX: "arm64\\.deb$" # choose the matching asset (regex)
35+
36+
ROUTER_REPO: arduino/arduino-router
37+
ROUTER_TAG: v0.5.3 # or "" to auto-use latest
38+
ROUTER_REGEX: "amd64\\.deb$" # e.g. change to "arm64\\.deb$" if you need arm64
39+
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
44+
- name: Set up Go
45+
uses: actions/setup-go@v5
46+
with:
47+
go-version-file: go.mod
48+
49+
# - name: Set up Docker
50+
# uses: docker/setup-docker-action@v2
51+
52+
# - name: Set up Docker Buildx
53+
# uses: docker/setup-buildx-action@v3
54+
55+
- name: Install Task (go-task)
56+
run: |
57+
go tool task --version
58+
59+
- name: Prepare folder
60+
run: |
61+
mkdir -p "${STABLE_DIR}"
62+
63+
- name: Checkout
64+
uses: actions/checkout@v4
65+
66+
67+
- name: Configure Git for private repo cloning
68+
env:
69+
GITHUB_USERNAME: ${{ secrets.GITHUB_USERNAME }}
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: |
72+
git config --global url."https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com".insteadOf "https://github.com"
73+
74+
- name: Install jq & curl
75+
run: |
76+
sudo apt-get update
77+
sudo apt-get install -y jq curl
78+
79+
- name: Fetch .debs dynamically into build/stable
80+
env:
81+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # for private access; use a PAT with repo scope if needed
82+
run: |
83+
set -euo pipefail
84+
mkdir -p build/stable
85+
86+
fetch_deb () {
87+
local repo="$1" tag="${2:-}" regex="$3"
88+
89+
echo "==> Resolving release for ${repo} (tag='${tag:-<latest>}')"
90+
if [ -n "${tag}" ]; then
91+
url="https://api.github.com/repos/${repo}/releases/tags/${tag}"
92+
else
93+
url="https://api.github.com/repos/${repo}/releases/latest"
94+
fi
95+
96+
# Get release JSON
97+
rel="$(curl -sfL -H "Authorization: token ${GH_TOKEN}" -H "Accept: application/vnd.github+json" "${url}")"
98+
99+
# Extract asset that matches regex
100+
name="$(echo "$rel" | jq -r --arg re "${regex}" '.assets[] | select(.name | test($re)) | .name' | head -n1)"
101+
dl="$(echo "$rel" | jq -r --arg re "${regex}" '.assets[] | select(.name | test($re)) | .browser_download_url' | head -n1)"
102+
103+
if [ -z "${name}" ] || [ "${name}" = "null" ] || [ -z "${dl}" ] || [ "${dl}" = "null" ]; then
104+
echo "!! No asset found in ${repo} matching regex: ${regex}"
105+
echo " Available assets were:"
106+
echo "$rel" | jq -r '.assets[].name'
107+
exit 1
108+
fi
109+
110+
echo "Found asset: ${name}"
111+
echo "Downloading: ${dl}"
112+
curl -sfL -H "Authorization: token ${GH_TOKEN}" -o "build/stable/${name}" "${dl}"
113+
ls -lh "build/stable/${name}"
114+
}
115+
116+
# Arduino App CLI
117+
fetch_deb "${APPCLI_REPO}" "${APPCLI_TAG}" "${APPCLI_REGEX}"
118+
119+
# Arduino Router
120+
fetch_deb "${ROUTER_REPO}" "${ROUTER_TAG}" "${ROUTER_REGEX}"
121+
- name: List assets for Arduino App CLI v0.6.6
122+
env:
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124+
run: |
125+
curl -H "Authorization: token ${GITHUB_TOKEN}" \
126+
-H "Accept: application/vnd.github+json" \
127+
"https://api.github.com/repos/arduino/arduino-app-cli/releases/tags/v0.6.6" \
128+
| jq -r '.assets[] | "\(.name) -> \(.browser_download_url)"'
129+
130+
- name: Download Arduino App CLI .deb
131+
run: |
132+
mkdir -p build/stable
133+
wget -O build/stable/arduino-app-cli_0.6.6_amd64.deb \
134+
https://github.com/arduino/arduino-app-cli/releases/download/0.6.6/arduino-app-cli_0.6.6_amd64.deb
135+
136+
- name: Download Arduino Router .deb
137+
run: |
138+
mkdir -p build/stable
139+
wget -O build/stable/arduino-router_0.5.3_amd64.deb \
140+
https://github.com/arduino/arduino-router/releases/download/v0.5.3/arduino-router_0.5.3_amd64.deb
141+
142+
- name: Build Docker image (no cache)
143+
run: |
144+
docker build --no-cache -t mock-apt-repo -f test.Dockerfile .
145+
146+
- name: Run mock-apt-repo container
147+
run: |
148+
docker run --rm -d \
149+
--privileged \
150+
--cgroupns=host \
151+
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
152+
-v /var/run/docker.sock:/var/run/docker.sock \
153+
-e DOCKER_HOST=unix:///var/run/docker.sock \
154+
--name apt-test-update \
155+
mock-apt-repo
156+
157+
- name: Verify container is running
158+
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)