Skip to content

Commit b0603b9

Browse files
authored
Update content_id_periodic_check.yml
1 parent 3e2c5d0 commit b0603b9

File tree

1 file changed

+0
-93
lines changed

1 file changed

+0
-93
lines changed
Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1 @@
1-
name: Check md files vs API
21

3-
on:
4-
schedule:
5-
- cron: "20 6 * * *" # every day at 06:20 UTC
6-
workflow_dispatch:
7-
inputs:
8-
branch:
9-
description: "Branch to check files in"
10-
required: true
11-
default: "gh-action-for-ids"
12-
13-
env:
14-
BASE_URL: ${{ secrets.BASE_URL }}
15-
NETWORK_ID: ${{ secrets.NETWORK_ID }}
16-
API_KEY: ${{ secrets.MERAKI_API_KEY }}
17-
18-
jobs:
19-
compare_md_with_api:
20-
runs-on: ubuntu-latest
21-
steps:
22-
- name: Checkout repository
23-
uses: actions/checkout@v3
24-
with:
25-
ref: ${{ github.event.inputs.branch }}
26-
27-
- name: Install jq
28-
run: sudo apt-get update && sudo apt-get install -y jq
29-
30-
- name: Compare .md files with API
31-
shell: /usr/bin/bash
32-
run: |
33-
REF_FILE_CF="docs/ContentFilteringCategories.md"
34-
REF_FILE_APP="docs/applicationCategories.md"
35-
API_TMP_CF="tmp_api_CF.md"
36-
API_TMP_APP="tmp_api_APP.md"
37-
MISMATCH=0
38-
39-
echo "=== Fetching contentFiltering categories ==="
40-
curl -s -H "X-Cisco-Meraki-API-Key: $API_KEY" \
41-
"$BASE_URL/networks/$NETWORK_ID/appliance/contentFiltering/categories" \
42-
| jq -r '.[] | "id: \(.id)\nname: \(.name)\n"' > "$API_TMP_CF"
43-
44-
echo "=== Comparing contentFiltering categories ==="
45-
while IFS= read -r ref_line; do
46-
api_line=$(grep -F "$ref_line" "$API_TMP_CF" || true)
47-
if [ -z "$api_line" ]; then
48-
echo "❌ Mismatch or missing line in API: '$ref_line'"
49-
MISMATCH=1
50-
fi
51-
done < "$REF_FILE_CF"
52-
53-
while IFS= read -r api_line; do
54-
ref_line=$(grep -F "$api_line" "$REF_FILE_CF" || true)
55-
if [ -z "$ref_line" ]; then
56-
echo "⚠ Extra line in API not in reference: '$api_line'"
57-
MISMATCH=1
58-
fi
59-
done < "$API_TMP_CF"
60-
61-
echo "=== Fetching application categories ==="
62-
curl -s -H "X-Cisco-Meraki-API-Key: $API_KEY" \
63-
"$BASE_URL/networks/$NETWORK_ID/appliance/firewall/l7FirewallRules/applicationCategories" \
64-
| jq -r '
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"
72-
73-
echo "=== Comparing application categories ==="
74-
while IFS= read -r ref_line; do
75-
api_line=$(grep -F "$ref_line" "$API_TMP_APP" || true)
76-
if [ -z "$api_line" ]; then
77-
echo "❌ Mismatch or missing line in API: '$ref_line'"
78-
MISMATCH=1
79-
fi
80-
done < "$REF_FILE_APP"
81-
82-
while IFS= read -r api_line; do
83-
ref_line=$(grep -F "$api_line" "$REF_FILE_APP" || true)
84-
if [ -z "$ref_line" ]; then
85-
echo "⚠ Extra line in API not in reference: '$api_line'"
86-
MISMATCH=1
87-
fi
88-
done < "$API_TMP_APP"
89-
90-
if [ $MISMATCH -eq 1 ]; then
91-
echo "❌ Category/application mismatches detected. Failing workflow."
92-
exit 1
93-
else
94-
echo "✅ All categories and applications match reference."

0 commit comments

Comments
 (0)