File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- name : ADJ Validator
1+ name : ADJ Validator (and Compact)
22
33on :
4- push :
4+ push :
55 pull_request :
66
77jobs :
4141 }' | curl -X POST -H "Content-type: application/json" \
4242 --data @- \
4343 $SLACK_WEBHOOK
44+
45+ publish-compact-adj :
46+ needs : validate-adj
47+ runs-on : ubuntu-latest
48+ env :
49+ TARGET_REPO : Hyperloop-UPV/ADJ-Archive
50+ TARGET_BRANCH : main
51+ TARGET_PATH : storage/commit-${{ github.sha }}.json
52+
53+ steps :
54+ - name : Checkout source repository
55+ uses : actions/checkout@v4
56+
57+ - name : Compact ADJ
58+ run : |
59+ chmod +x .github/workflows/scripts/adj-compact/compact.sh
60+ .github/workflows/scripts/adj-compact/compact.sh "${{ runner.temp }}/adj.json"
61+
62+ - name : Upload to destination repo via API
63+ env :
64+ GH_TOKEN : ${{ secrets.TARGET_REPO_TOKEN }}
65+ run : |
66+ base64 -w0 "${{ runner.temp }}/adj.json" > "${{ runner.temp }}/adj.b64"
67+ jq -n \
68+ --arg message "chore: add compacted ADJ from ${{ github.repository }}@${{ github.sha }}" \
69+ --rawfile content "${{ runner.temp }}/adj.b64" \
70+ --arg branch "$TARGET_BRANCH" \
71+ '{message: $message, content: $content, branch: $branch}' \
72+ > "${{ runner.temp }}/body.json"
73+ curl --fail-with-body -sS -X PUT \
74+ -H "Authorization: Bearer $GH_TOKEN" \
75+ -H "Accept: application/vnd.github+json" \
76+ -H "X-GitHub-Api-Version: 2022-11-28" \
77+ --data "@${{ runner.temp }}/body.json" \
78+ "https://api.github.com/repos/${TARGET_REPO}/contents/${TARGET_PATH}"
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ # Javier Ribal del Río
5+ # ADJ Compact: Merge all JSON files into a single `adj.json` for easier consumption by clients that prefer a single file.
6+ # Usage: `./compact.sh [output-file]`
7+ # Version: v11.0.0 (2026-05-18)
8+ #
9+
10+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
11+ ROOT=" $( git -C " $SCRIPT_DIR " rev-parse --show-toplevel 2> /dev/null || (cd " $SCRIPT_DIR /../../../.." && pwd)) "
12+ OUT=" ${1:- ${ROOT} / adj.json} "
13+ OUT_BASE=" $( basename " $OUT " ) "
14+
15+ cd " $ROOT "
16+
17+ acc=' {}'
18+ # Sort shallowest-first so files like `boards.json` are merged before `boards/X/Y.json`,
19+ # letting the deeper, more specific content override the index-file stubs.
20+ while IFS= read -r rel; do
21+ [[ -z " $rel " ]] && continue
22+ [[ " $rel " == " $OUT_BASE " ]] && continue
23+ key=" ${rel% .json} "
24+ acc=$( jq -c --arg k " $key " --slurpfile v " $rel " '
25+ ($k | split("/")) as $p
26+ | . * ([{($p[-1]): $v[0]}] | .[0] | reduce ($p[:-1] | reverse)[] as $seg (.; {($seg): .}))
27+ ' <<< " $acc" )
28+ done < <( find . -type d -name .github -prune -o -type f -name ' *.json' -printf ' %d %p\n' | sort -n | sed ' s|^[0-9]* \./||' )
29+
30+ printf ' %s\n' " $acc " > " $OUT "
31+ echo " Wrote $OUT "
You can’t perform that action at this time.
0 commit comments