-
Notifications
You must be signed in to change notification settings - Fork 3
64 lines (56 loc) · 1.63 KB
/
Copy pathbicep-lint.yml
File metadata and controls
64 lines (56 loc) · 1.63 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
name: Bicep Lint
on:
pull_request:
paths:
- '**/*.bicep'
- 'bicepconfig.json'
- '.github/workflows/bicep-lint.yml'
push:
branches:
- main
paths:
- '**/*.bicep'
- 'bicepconfig.json'
workflow_dispatch:
permissions:
contents: read
jobs:
lint-bicep:
name: lint-bicep
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/azure-cli:2.62.0
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect Bicep files
id: detect
shell: bash
run: |
set -euo pipefail
mapfile -t FILES < <(find . -type f -name '*.bicep' -not -path './.git/*' | sed 's|^\./||')
if [ ${#FILES[@]} -eq 0 ]; then
echo "found=false" >> "$GITHUB_OUTPUT"
echo "No .bicep files found. Skipping lint/build."
else
echo "found=true" >> "$GITHUB_OUTPUT"
printf '%s\n' "${FILES[@]}" > bicep_files.txt
echo "Found Bicep files:"
cat bicep_files.txt
fi
- name: Install Bicep CLI
if: steps.detect.outputs.found == 'true'
shell: bash
run: az bicep install
- name: Build all Bicep files
if: steps.detect.outputs.found == 'true'
shell: bash
run: |
set -euo pipefail
while IFS= read -r file; do
echo "Validating $file"
az bicep build --file "$file" > /dev/null
done < bicep_files.txt
- name: No-op when no Bicep files
if: steps.detect.outputs.found != 'true'
run: echo "Bicep lint check passed (no .bicep files present)."