@@ -2,7 +2,7 @@ name: Check md files vs API
22
33on :
44 schedule :
5- - cron : " 20 6 * * *"
5+ - cron : " 20 6 * * *" # every day at 06:20 UTC
66 workflow_dispatch :
77 inputs :
88 branch :
1616 API_KEY : ${{ secrets.MERAKI_API_KEY }}
1717
1818jobs :
19- check_categories :
19+ compare_md_with_api :
2020 runs-on : ubuntu-latest
2121 steps :
22- - name : Checkout repo
22+ - name : Checkout repository
2323 uses : actions/checkout@v3
24+ with :
25+ ref : ${{ github.event.inputs.branch }}
2426
2527 - name : Install jq
26- run : sudo apt-get install -y jq
28+ run : sudo apt-get update && sudo apt-get install -y jq
2729
28- - name : Check contentFiltering categories
30+ - name : Compare .md files with API
31+ shell : /usr/bin/bash
2932 run : |
3033 REF_FILE_CF="docs/ContentFilteringCategories.md"
34+ REF_FILE_APP="docs/applicationCategories.md"
3135 API_TMP_CF="tmp_api_CF.md"
36+ API_TMP_APP="tmp_api_APP.md"
3237 MISMATCH=0
3338
3439 echo "=== Fetching contentFiltering categories ==="
4550 fi
4651 done < "$REF_FILE_CF"
4752
48- # Check for extra items in API not in reference
4953 while IFS= read -r api_line; do
5054 ref_line=$(grep -F "$api_line" "$REF_FILE_CF" || true)
5155 if [ -z "$ref_line" ]; then
@@ -54,26 +58,17 @@ jobs:
5458 fi
5559 done < "$API_TMP_CF"
5660
57- if [ $MISMATCH -eq 1 ]; then
58- echo "contentFiltering categories mismatch detected. Failing workflow."
59- exit 1
60- else
61- echo "✅ All contentFiltering categories match reference."
62-
63- - name : Check application categories
64- run : |
65- REF_FILE_APP="docs/applicationCategories.md"
66- API_TMP_APP="tmp_api_APP.md"
67- MISMATCH=0
68-
6961 echo "=== Fetching application categories ==="
7062 curl -s -H "X-Cisco-Meraki-API-Key: $API_KEY" \
7163 "$BASE_URL/networks/$NETWORK_ID/appliance/firewall/l7FirewallRules/applicationCategories" \
7264 | jq -r '
73- .applicationCategories[] as $cat |
74- "id: \($cat.id)\nname: \($cat.name)\n" +
75- ($cat.applications[]? | " id: \(.id)\n name: \(.name)\n")
76- ' > "$API_TMP_APP"
65+ .applicationCategories[] |
66+ "category_id: \(.id)\ncategory_name: \(.name)" + (
67+ if .applications then
68+ "\n" + (.applications[] | " app_id: \(.id)\n app_name: \(.name)")
69+ else "" end
70+ )
71+ ' > "$API_TMP_APP"
7772
7873 echo "=== Comparing application categories ==="
7974 while IFS= read -r ref_line; do
8479 fi
8580 done < "$REF_FILE_APP"
8681
87- # Check for extra items in API not in reference
8882 while IFS= read -r api_line; do
8983 ref_line=$(grep -F "$api_line" "$REF_FILE_APP" || true)
9084 if [ -z "$ref_line" ]; then
9488 done < "$API_TMP_APP"
9589
9690 if [ $MISMATCH -eq 1 ]; then
97- echo "application categories mismatch detected. Failing workflow."
91+ echo "❌ Category/ application mismatches detected. Failing workflow."
9892 exit 1
9993 else
100- echo "✅ All application categories match reference."
94+ echo "✅ All categories and applications match reference."
0 commit comments