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 : Validate Profiles
2+
3+ on :
4+ push :
5+ branches : [main]
6+ pull_request :
7+ branches : [main]
8+
9+ jobs :
10+ validate :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - uses : actions/checkout@v5
14+
15+ - name : Build profiles archive
16+ run : bash make_profiles_archive.sh profiles.zip
17+
18+ - name : Validate profiles
19+ run : |
20+ response=$(curl -sf -w "\n%{http_code}" \
21+ -X POST https://api.enapter.com/v3/blueprints/device_profiles/validate \
22+ -H "Content-Type: application/zip" \
23+ --data-binary @profiles.zip)
24+ body=$(echo "$response" | head -n -1 | jq .)
25+ status=$(echo "$response" | tail -n 1)
26+ echo "$body"
27+ if [ "$status" -lt 200 ] || [ "$status" -ge 300 ]; then
28+ echo "Validation failed with HTTP $status"
29+ exit 1
30+ fi
31+ if [ "$(echo "$body" | jq '.validation_errors | length')" -gt 0 ]; then
32+ exit 1
33+ fi
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ REPO_ROOT=" $( cd " $( dirname " $0 " ) " && pwd) "
5+ OUTPUT=" ${1:- profiles.zip} "
6+
7+ # Use a temp dir for staging
8+ STAGING=$( mktemp -d)
9+ trap ' rm -rf "$STAGING"' EXIT
10+
11+ find " $REPO_ROOT " -name " *.yml" -not -path ' */.github/*' | while read -r file; do
12+ # Get path relative to repo root
13+ rel=" ${file# " $REPO_ROOT " / } "
14+ # Convert path to folder name: replace / with . and strip .yml
15+ folder=" ${rel% .yml} "
16+ folder=" ${folder// \/ / .} "
17+ # Copy file as manifest.yml inside the folder
18+ mkdir -p " $STAGING /$folder "
19+ cp " $file " " $STAGING /$folder /manifest.yml"
20+ done
21+
22+ # Create the zip from the staging dir
23+ (cd " $STAGING " && zip -r - .) > " $OUTPUT "
24+
25+ echo " Created $OUTPUT "
You can’t perform that action at this time.
0 commit comments