@@ -9,134 +9,76 @@ permissions:
99 security-events : write
1010
1111jobs :
12- powershell :
13- name : PowerShell Script Analysis
14- runs-on : windows-latest
15-
16- steps :
17- - name : Skip for Release Please
18- if : ${{ startsWith(github.head_ref, 'release-please--branches--') }}
19- run : echo "Skipping PowerShell analysis for Release Please PR"
20-
21- - uses : actions/checkout@v5
22- if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
23-
24- - name : Run PSScriptAnalyzer
25- if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
26- uses : microsoft/psscriptanalyzer-action@v1.1
27- with :
28- path : ./scripts/windows
29- recurse : true
30- output : results.sarif
31- ignorePattern : ' \.git|\.github'
32-
33- - name : Upload PSScriptAnalyzer results
34- uses : github/codeql-action/upload-sarif@v3
35- if : ${{ always() && ! startsWith(github.head_ref, 'release-please--branches--') }}
36- with :
37- sarif_file : results.sarif
38-
39- shellcheck :
40- name : Shell Script Analysis
12+ pre-commit :
13+ name : Run Pre-Commit Checks
14+ if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
4115 runs-on : ubuntu-latest
4216
4317 steps :
44- - name : Skip for Release Please
45- if : ${{ startsWith(github.head_ref, 'release-please--branches--') }}
46- run : echo "Skipping Shell Script analysis for Release Please PR"
47-
48- - uses : actions/checkout@v5
49- if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
50-
51- - name : Run ShellCheck
52- if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
53- uses : ludeeus/action-shellcheck@master
54- with :
55- scandir : ' ./scripts'
56- ignore_paths : ' scripts/windows'
57- severity : warning
58-
59- markdown :
60- name : Markdown Lint
61- runs-on : ubuntu-latest
18+ - name : Checkout code
19+ uses : actions/checkout@v5
6220
63- steps :
64- - name : Skip for Release Please
65- if : ${{ startsWith(github.head_ref, 'release-please--branches--') }}
66- run : echo "Skipping Markdown lint for Release Please PR"
67-
68- - uses : actions/checkout@v5
69- if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
70-
71- - name : Run markdownlint
72- if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
73- uses : DavidAnson/markdownlint-cli2-action@v20
74- with :
75- globs : |
76- **/*.md
77- !node_modules/**
78- !CHANGELOG.md
79-
80- json-yaml :
81- name : JSON/YAML Validation
82- runs-on : ubuntu-latest
21+ - name : Set up Python
22+ uses : actions/setup-python@v5
23+ with :
24+ python-version : ' 3.12'
25+
26+ - name : Install pre-commit
27+ run : pip install pre-commit
28+
29+ - name : Set up Node.js for markdownlint
30+ uses : actions/setup-node@v4
31+ with :
32+ node-version : ' 20'
33+
34+ - name : Install markdownlint-cli2
35+ run : npm install -g markdownlint-cli2
36+
37+ - name : Run pre-commit hooks (except PSScriptAnalyzer)
38+ run : |
39+ # Skip PSScriptAnalyzer as it requires Windows
40+ SKIP=psscriptanalyzer pre-commit run --all-files --show-diff-on-failure
41+
42+ powershell :
43+ name : PowerShell Script Analysis
44+ if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
45+ runs-on : windows-latest
8346
8447 steps :
85- - name : Skip for Release Please
86- if : ${{ startsWith(github.head_ref, 'release-please--branches--') }}
87- run : echo "Skipping JSON/YAML validation for Release Please PR"
88-
89- - uses : actions/checkout@v5
90- if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
91-
92- - name : Validate JSON files
93- if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
94- run : |
95- find . -name "*.json" -type f -not -path "./node_modules/*" | while read file; do
96- echo "Validating $file"
97- python -m json.tool "$file" > /dev/null || exit 1
98- done
99- echo "All JSON files are valid"
100-
101- - name : Setup Python
102- if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
103- uses : actions/setup-python@v5
104- with :
105- python-version : ' 3.x'
106-
107- - name : Validate YAML files
108- if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
109- run : |
110- pip install pyyaml
111- find . -name "*.yml" -o -name "*.yaml" -type f -not -path "./node_modules/*" | while read file; do
112- echo "Validating $file"
113- python -c "import yaml; yaml.safe_load(open('$file'))" || exit 1
114- done
115- echo "All YAML files are valid"
48+ - uses : actions/checkout@v5
49+
50+ - name : Run PSScriptAnalyzer
51+ uses : microsoft/psscriptanalyzer-action@v1.1
52+ with :
53+ path : ./scripts/windows
54+ recurse : true
55+ output : results.sarif
56+ ignorePattern : ' \.git|\.github'
57+
58+ - name : Upload PSScriptAnalyzer results
59+ uses : github/codeql-action/upload-sarif@v3
60+ if : always()
61+ with :
62+ sarif_file : results.sarif
11663
11764 security :
11865 name : Security Scan
66+ if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
11967 runs-on : ubuntu-latest
12068
12169 steps :
122- - name : Skip for Release Please
123- if : ${{ startsWith(github.head_ref, 'release-please--branches--') }}
124- run : echo "Skipping Trivy security scan for Release Please PR"
125-
126- - uses : actions/checkout@v5
127- if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
128-
129- - name : Run Trivy security scanner
130- if : ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
131- uses : aquasecurity/trivy-action@master
132- with :
133- scan-type : ' fs'
134- scan-ref : ' .'
135- format : ' sarif'
136- output : ' trivy-results.sarif'
137-
138- - name : Upload Trivy results to GitHub Security
139- uses : github/codeql-action/upload-sarif@v3
140- if : ${{ always() && ! startsWith(github.head_ref, 'release-please--branches--') }}
141- with :
142- sarif_file : ' trivy-results.sarif'
70+ - uses : actions/checkout@v5
71+
72+ - name : Run Trivy security scanner
73+ uses : aquasecurity/trivy-action@master
74+ with :
75+ scan-type : ' fs'
76+ scan-ref : ' .'
77+ format : ' sarif'
78+ output : ' trivy-results.sarif'
79+
80+ - name : Upload Trivy results to GitHub Security
81+ uses : github/codeql-action/upload-sarif@v3
82+ if : always()
83+ with :
84+ sarif_file : ' trivy-results.sarif'
0 commit comments