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+ pull_request :
6+
7+ jobs :
8+ validate :
9+ runs-on : ubuntu-latest
10+ steps :
11+ - uses : actions/checkout@v4
12+
13+ - name : Build profiles archive
14+ run : bash make_profiles_archive.sh profiles.zip
15+
16+ - name : Validate profiles
17+ run : |
18+ response=$(curl -sf -w "\n%{http_code}" \
19+ -X POST https://api.enapter.com/v3/blueprints/device_profiles/validate \
20+ -H "Content-Type: application/zip" \
21+ --data-binary @profiles.zip)
22+ body=$(echo "$response" | head -n -1)
23+ status=$(echo "$response" | tail -n 1)
24+ echo "$body"
25+ if [ "$status" -lt 200 ] || [ "$status" -ge 300 ]; then
26+ echo "Validation failed with HTTP $status"
27+ exit 1
28+ 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