Skip to content

dind

dind #14

Workflow file for this run

name: Build & Update with Arduino CLI
on:
push:
branches:
- main
- test_package_update
workflow_dispatch:
permissions:
contents: read
jobs:
build-and-update:
runs-on: ubuntu-22.04
# services:
# docker:
# image: docker:dind
# options: --privileged --shm-size=2g
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock:ro
# container:
# image: ubuntu:latest
env:
ARCH: amd64
APPCLI_REPO: arduino/arduino-app-cli
ROUTER_REPO: arduino/arduino-router
STABLE_DIR: build/stable
# ---- Configure what to fetch ----
# Use a specific tag (with leading v) or leave empty to use the latest stable release.
APPCLI_TAG: v0.6.6 # or "" to auto-use latest
APPCLI_REGEX: "arm64\\.deb$" # choose the matching asset (regex)
ROUTER_TAG: v0.5.3 # or "" to auto-use latest
ROUTER_REGEX: "amd64\\.deb$" # e.g. change to "arm64\\.deb$" if you need arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
# - name: Set up Docker
# uses: docker/setup-docker-action@v2
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
- name: Install Task (go-task)
run: |
go tool task --version
- name: Prepare folder
run: |
mkdir -p "${STABLE_DIR}"
- name: Checkout
uses: actions/checkout@v4
- name: Configure Git for private repo cloning
env:
GITHUB_USERNAME: ${{ secrets.GITHUB_USERNAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global url."https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com".insteadOf "https://github.com"
- name: Install jq & curl
run: |
sudo apt-get update
sudo apt-get install -y jq curl
- name: Fetch .debs dynamically into build/stable
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # for private access; use a PAT with repo scope if needed
run: |
set -euo pipefail
mkdir -p build/stable
fetch_deb () {
local repo="$1" tag="${2:-}" regex="$3"
echo "==> Resolving release for ${repo} (tag='${tag:-<latest>}')"
if [ -n "${tag}" ]; then
url="https://api.github.com/repos/${repo}/releases/tags/${tag}"
else
url="https://api.github.com/repos/${repo}/releases/latest"
fi
# Get release JSON
rel="$(curl -sfL -H "Authorization: token ${GH_TOKEN}" -H "Accept: application/vnd.github+json" "${url}")"
# Extract asset that matches regex
name="$(echo "$rel" | jq -r --arg re "${regex}" '.assets[] | select(.name | test($re)) | .name' | head -n1)"
dl="$(echo "$rel" | jq -r --arg re "${regex}" '.assets[] | select(.name | test($re)) | .browser_download_url' | head -n1)"
if [ -z "${name}" ] || [ "${name}" = "null" ] || [ -z "${dl}" ] || [ "${dl}" = "null" ]; then
echo "!! No asset found in ${repo} matching regex: ${regex}"
echo " Available assets were:"
echo "$rel" | jq -r '.assets[].name'
exit 1
fi
echo "Found asset: ${name}"
echo "Downloading: ${dl}"
curl -sfL -H "Authorization: token ${GH_TOKEN}" -o "build/stable/${name}" "${dl}"
ls -lh "build/stable/${name}"
}
# Arduino App CLI
fetch_deb "${APPCLI_REPO}" "${APPCLI_TAG}" "${APPCLI_REGEX}"
# Arduino Router
fetch_deb "${ROUTER_REPO}" "${ROUTER_TAG}" "${ROUTER_REGEX}"
- name: List assets for Arduino App CLI v0.6.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -H "Authorization: token ${GITHUB_TOKEN}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/arduino/arduino-app-cli/releases/tags/v0.6.6" \
| jq -r '.assets[] | "\(.name) -> \(.browser_download_url)"'
- name: Download Arduino App CLI .deb
run: |
mkdir -p build/stable
wget -O build/stable/arduino-app-cli_0.6.6_amd64.deb \
https://github.com/arduino/arduino-app-cli/releases/download/0.6.6/arduino-app-cli_0.6.6_amd64.deb
- name: Download Arduino Router .deb
run: |
mkdir -p build/stable
wget -O build/stable/arduino-router_0.5.3_amd64.deb \
https://github.com/arduino/arduino-router/releases/download/v0.5.3/arduino-router_0.5.3_amd64.deb
- name: Build Docker image (no cache)
run: |
docker build --no-cache -t mock-apt-repo -f test.Dockerfile .
- name: Run mock-apt-repo container
run: |
docker run --rm -d \
--privileged \
--cgroupns=host \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
-v /var/run/docker.sock:/var/run/docker.sock \
-e DOCKER_HOST=unix:///var/run/docker.sock \
--name apt-test-update \
mock-apt-repo
- name: Verify container is running
run: docker ps