Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Validate Profiles

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- name: Build profiles archive
run: bash make_profiles_archive.sh profiles.zip

- name: Validate profiles
run: |
response=$(curl -sf -w "\n%{http_code}" \
-X POST https://api.enapter.com/v3/blueprints/device_profiles/validate \
-H "Content-Type: application/zip" \
--data-binary @profiles.zip)
body=$(echo "$response" | head -n -1 | jq .)
status=$(echo "$response" | tail -n 1)
echo "$body"
if [ "$status" -lt 200 ] || [ "$status" -ge 300 ]; then
echo "Validation failed with HTTP $status"
exit 1
fi
if [ "$(echo "$body" | jq '.validation_errors | length')" -gt 0 ]; then
exit 1
fi
25 changes: 25 additions & 0 deletions make_profiles_archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail

REPO_ROOT="$(cd "$(dirname "$0")" && pwd)"
OUTPUT="${1:-profiles.zip}"

# Use a temp dir for staging
STAGING=$(mktemp -d)
trap 'rm -rf "$STAGING"' EXIT

find "$REPO_ROOT" -name "*.yml" -not -path '*/.github/*' | while read -r file; do
# Get path relative to repo root
rel="${file#"$REPO_ROOT"/}"
# Convert path to folder name: replace / with . and strip .yml
folder="${rel%.yml}"
folder="${folder//\//.}"
# Copy file as manifest.yml inside the folder
mkdir -p "$STAGING/$folder"
cp "$file" "$STAGING/$folder/manifest.yml"
done

# Create the zip from the staging dir
(cd "$STAGING" && zip -r - .) > "$OUTPUT"

echo "Created $OUTPUT"