Skip to content

Commit d6cf181

Browse files
Add GitHub workflow to scan project with CodeQL
- Set up CodeQL analysis workflow to scan both the Kubebuilder CLI and generated projects in 'testdata'. - Run 'make install' in the root directory to build and install the Kubebuilder CLI as part of the setup. - For sample projects in 'testdata' (e.g., project-v4), add a step to run 'make all' to ensure all resources are generated and ready for analysis. - Configure the manual build mode for Go projects in 'testdata' to run 'make manifests' and 'make build' if autobuild is insufficient.
1 parent f7a02ad commit d6cf181

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/codeql.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: "CodeQL Advanced"
2+
3+
on:
4+
# We are checking master and book-v4 because book-v4 has always the code
5+
# from the latest release
6+
push:
7+
branches: ["master", "book-v4"]
8+
pull_request:
9+
branches: ["master", "book-v4"]
10+
schedule:
11+
- cron: '30 20 * * 1' # Runs a periodic scan every Monday at 8:30 PM
12+
13+
jobs:
14+
analyze:
15+
name: Analyze (${{ matrix.language }})
16+
runs-on: ubuntu-latest
17+
permissions:
18+
security-events: write
19+
packages: read
20+
actions: read
21+
contents: read
22+
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- language: go
28+
build-mode: autobuild
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Go
35+
uses: actions/setup-go@v4
36+
with:
37+
go-version: '1.22'
38+
39+
- name: Install Kubebuilder tools
40+
run: |
41+
go install sigs.k8s.io/controller-tools/cmd/[email protected]
42+
go install sigs.k8s.io/kustomize/kustomize/[email protected]
43+
44+
- name: Build and install Kubebuilder CLI
45+
run: make install
46+
47+
# Construa apenas o projeto project-v4 no diretório testdata
48+
- name: Build project-v4 sample project
49+
run: |
50+
cd testdata/project-v4
51+
go mod tidy
52+
make all
53+
54+
- name: Initialize CodeQL
55+
uses: github/codeql-action/init@v3
56+
with:
57+
languages: ${{ matrix.language }}
58+
build-mode: ${{ matrix.build-mode }}
59+
60+
- if: matrix.language == 'go' && matrix.build-mode == 'manual'
61+
shell: bash
62+
run: |
63+
cd testdata/project-v4
64+
go mod tidy
65+
echo 'Running manual build commands for Go in project-v4'
66+
make manifests
67+
make build
68+
69+
- name: Perform CodeQL Analysis
70+
uses: github/codeql-action/analyze@v3
71+
with:
72+
category: "/language:${{matrix.language}}"

0 commit comments

Comments
 (0)