From 551f65ec52384d37e15ffbf18e626ce2c581f899 Mon Sep 17 00:00:00 2001 From: nandi <78769380+codegod100@users.noreply.github.com> Date: Sat, 8 Aug 2026 11:10:39 -0700 Subject: [PATCH] Trigger boxci merge builds for APK and Flatpak on push to main. Post to boxci.boxd.sh after merge so the boxd runner can build artifacts using the same nix attrs as Buildkite/GHA without duplicating build logic. Co-authored-by: Cursor --- .github/workflows/boxci-merge.yml | 44 ++++++++++++++++ scripts/boxci/dispatch-merge.sh | 87 +++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 .github/workflows/boxci-merge.yml create mode 100755 scripts/boxci/dispatch-merge.sh diff --git a/.github/workflows/boxci-merge.yml b/.github/workflows/boxci-merge.yml new file mode 100644 index 0000000..d704038 --- /dev/null +++ b/.github/workflows/boxci-merge.yml @@ -0,0 +1,44 @@ +# Trigger boxci sleek-merge pipeline on push to main (post-merge APK + Flatpak). +# boxci runs on https://boxci.boxd.sh — see boxci/pipelines/sleek-merge.yml. +# +# Manual: ./scripts/boxci/dispatch-merge.sh + +name: boxci merge + +on: + push: + branches: [main] + +concurrency: + group: boxci-merge-${{ github.sha }} + cancel-in-progress: false + +jobs: + trigger: + name: Trigger boxci merge build + runs-on: ubuntu-latest + steps: + - name: POST boxci /api/runs + env: + BOXCI_URL: https://boxci.boxd.sh + run: | + set -euo pipefail + payload="$(jq -n \ + --arg pipeline "sleek-merge.yml" \ + --arg trigger "merge" \ + --arg sha "${{ github.sha }}" \ + --arg ref "${{ github.ref }}" \ + '{ + pipeline: $pipeline, + env: { + BOXCI_TRIGGER: $trigger, + GIT_SHA: $sha, + GIT_REF: $ref, + SLEEK_BRANCH: "main" + } + }')" + echo "POST ${BOXCI_URL}/api/runs" + curl -fsSL -X POST "${BOXCI_URL}/api/runs" \ + -H "Content-Type: application/json" \ + -d "$payload" \ + | jq '{id, status, pipeline, duration_s}' diff --git a/scripts/boxci/dispatch-merge.sh b/scripts/boxci/dispatch-merge.sh new file mode 100755 index 0000000..3ef24a9 --- /dev/null +++ b/scripts/boxci/dispatch-merge.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +# Trigger boxci sleek-merge pipeline (APK + Flatpak after merge to main). +# +# Usage: +# ./scripts/boxci/dispatch-merge.sh +# ./scripts/boxci/dispatch-merge.sh --sha abc1234 +# +# Env: +# BOXCI_URL — default https://boxci.boxd.sh +# SLEEK_BRANCH — default main +# OPENBAO_TOKEN — optional; not required for trigger itself +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" +cd "$REPO_ROOT" + +usage() { + sed -n '2,12p' "$0" + exit 2 +} + +SHA="" +while [[ $# -gt 0 ]]; do + case "$1" in + --sha) + [[ $# -ge 2 ]] || usage + SHA="$2" + shift 2 + ;; + -h | --help) + usage + ;; + *) + if [[ -z "$SHA" && "$1" =~ ^[0-9a-fA-F]{7,40}$ ]]; then + SHA="$1" + shift + else + echo "dispatch-merge: unknown arg: $1" >&2 + usage + fi + ;; + esac +done + +BOXCI_URL="${BOXCI_URL:-https://boxci.boxd.sh}" +BRANCH="${SLEEK_BRANCH:-main}" + +command -v curl >/dev/null 2>&1 || { echo "curl required" >&2; exit 1; } +command -v jq >/dev/null 2>&1 || { echo "jq required" >&2; exit 1; } + +if [[ -z "$SHA" ]]; then + command -v git >/dev/null 2>&1 || { echo "git required (or pass --sha)" >&2; exit 1; } + SHA="$(git rev-parse "$BRANCH")" +fi + +payload="$(jq -n \ + --arg pipeline "sleek-merge.yml" \ + --arg trigger "merge" \ + --arg sha "$SHA" \ + --arg branch "$BRANCH" \ + '{ + pipeline: $pipeline, + env: { + BOXCI_TRIGGER: $trigger, + GIT_SHA: $sha, + SLEEK_BRANCH: $branch + } + }')" + +url="${BOXCI_URL%/}/api/runs" +echo "POST $url" +echo " pipeline=sleek-merge.yml BOXCI_TRIGGER=merge GIT_SHA=${SHA:0:7} branch=$BRANCH" + +response="$(curl -fsSL -X POST "$url" \ + -H "Content-Type: application/json" \ + -d "$payload")" + +run_id="$(echo "$response" | jq -r '.id // empty')" +status="$(echo "$response" | jq -r '.status // empty')" + +if [[ -n "$run_id" ]]; then + echo "run $run_id: $status" + echo "$response" | jq '{id, status, pipeline, duration_s, steps: [.steps[] | {key, label, status}]}' +else + echo "$response" | jq . +fi -- 2.51.2