Repository navigation
76 lines (73 loc) · 3.17 KB
/
Copy pathcodeql.yml
File metadata and controls
76 lines (73 loc) · 3.17 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
name: CodeQL
on:
push:
branches: [main, master]
pull_request:
schedule:
- cron: '23 6 * * 1'
workflow_dispatch:
permissions:
contents: read
jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-24.04
timeout-minutes: 25
# Job permissions replace the workflow's. actions: read lets CodeQL read workflow-run
# metadata, which a private repository requires; security-events: write uploads results.
permissions:
contents: read
actions: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [go, javascript-typescript, python]
steps:
# Code scanning is free for public repositories. A private repository needs a paid GitHub
# Code Security licence, and CodeQL's terms do not allow analysing private code without one.
# Without it the analysis cannot upload results, so the job reports that and stays green
# instead of failing. On a licensed private repository, set the repository variable
# CODEQL_PRIVATE_REPOSITORY to true to turn analysis on.
- name: Check whether code scanning is available
id: scope
env:
GH_TOKEN: ${{ github.token }}
LICENSED_PRIVATE: ${{ vars.CODEQL_PRIVATE_REPOSITORY }}
shell: bash
run: |
set -euo pipefail
private=$(gh api "repos/$GITHUB_REPOSITORY" --jq .private)
if [[ "$private" != true || "$LICENSED_PRIVATE" == true ]]; then
echo 'enabled=true' >> "$GITHUB_OUTPUT"
else
echo 'enabled=false' >> "$GITHUB_OUTPUT"
message='Code scanning is not available for this private repository. The analysis starts by itself once the repository is public. For a licensed private repository, set the CODEQL_PRIVATE_REPOSITORY variable to true.'
echo "::notice title=CodeQL not run::$message"
echo "$message" >> "$GITHUB_STEP_SUMMARY"
fi
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: steps.scope.outputs.enabled == 'true'
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
if: steps.scope.outputs.enabled == 'true' && matrix.language == 'go'
with:
go-version-file: go.mod
cache: false
- name: Install native build prerequisites
if: steps.scope.outputs.enabled == 'true' && matrix.language == 'go'
timeout-minutes: 10
run: bash scripts/install_linux_deps.sh
- uses: github/codeql-action/init@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
if: steps.scope.outputs.enabled == 'true'
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.language == 'go' && 'manual' || 'none' }}
- name: Build production Go code
if: steps.scope.outputs.enabled == 'true' && matrix.language == 'go'
run: go build -tags production,webkit2_41 ./...
- uses: github/codeql-action/analyze@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
if: steps.scope.outputs.enabled == 'true'
with:
category: /language:${{ matrix.language }}