-
Notifications
You must be signed in to change notification settings - Fork 1
82 lines (69 loc) · 2.55 KB
/
Copy pathvalidate.yml
File metadata and controls
82 lines (69 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: DISABLED - Validate Bicep Templates
on:
workflow_dispatch: {}
jobs:
bicep-validation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Bicep
run: |
# Install Bicep CLI
curl -Lo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64
chmod +x ./bicep
sudo mv ./bicep /usr/local/bin/bicep
bicep --version
- name: Validate Main Template
run: |
cd AzureArchitecture
bicep build main.bicep --outfile main.json
echo "✅ main.bicep compiled successfully"
- name: Validate Individual Modules
run: |
cd AzureArchitecture
for file in *.bicep; do
if [ "$file" != "main.bicep" ]; then
echo "Validating $file..."
bicep build "$file" --outfile "${file%.bicep}.json"
echo "✅ $file compiled successfully"
fi
done
- name: Check for Best Practices
run: |
cd AzureArchitecture
echo "🔍 Checking Bicep best practices..."
# Check for hardcoded locations
if grep -r "location.*:" *.bicep | grep -v "param location" | grep -v "location: location" | grep -v "location: region"; then
echo "⚠️ Found hardcoded locations. Consider using parameters."
fi
# Check for hardcoded resource names
if grep -r "name.*:" *.bicep | grep -E "'[a-zA-Z0-9-]+'" | head -5; then
echo "⚠️ Found potentially hardcoded resource names. Consider using parameters or variables."
fi
# Check for secure parameters
if grep -r "@secure" *.bicep; then
echo "✅ Found secure parameters - good practice for sensitive data"
fi
echo "✅ Best practices check completed"
schema-validation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate Parameter Files
run: |
cd AzureArchitecture
for file in *.parameters.json; do
if [ -f "$file" ]; then
echo "Validating parameter file: $file"
python3 -m json.tool "$file" > /dev/null
echo "✅ $file is valid JSON"
fi
done
# Validate example parameter files
for file in *.parameters.json.example; do
if [ -f "$file" ]; then
echo "Validating example parameter file: $file"
python3 -m json.tool "$file" > /dev/null
echo "✅ $file is valid JSON"
fi
done