-
Notifications
You must be signed in to change notification settings - Fork 88
executable file
·87 lines (75 loc) · 2.97 KB
/
Copy pathcodeql.yml
File metadata and controls
executable file
·87 lines (75 loc) · 2.97 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
83
84
85
86
87
name: "CodeQL"
on:
workflow_dispatch:
push:
pull_request:
branches:
- 'develop'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: ['python']
steps:
# For push events github.ref_name is the branch name.
# For PR events github.head_ref is the source branch name.
- name: Get branch name
id: extract_branch
shell: bash
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "branch=${{ github.head_ref }}" >>$GITHUB_OUTPUT
else
echo "branch=${{ github.ref_name }}" >>$GITHUB_OUTPUT
fi
# For push: check out the pushed branch from the repo (fork-aware via repository_owner).
# For PR: check out the exact PR commit from the source repo (handles fork PRs correctly).
- name: Checkout smarthome (push)
if: github.event_name != 'pull_request'
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/smarthome
ref: ${{ steps.extract_branch.outputs.branch }}
path: smarthomeng
- name: Checkout smarthome (pull request)
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
path: smarthomeng
- name: Check if branch '${{ steps.extract_branch.outputs.branch }}' exists in smarthomeNG/plugins
id: plugins_branch_check
run: echo "code=$(git ls-remote --exit-code --heads https://github.com/smarthomeNG/plugins ${{ steps.extract_branch.outputs.branch }} > /dev/null; echo $? )" >>$GITHUB_OUTPUT
- name: Checkout plugins from branch '${{ steps.extract_branch.outputs.branch }}' (push on known branch)
if: github.event_name != 'pull_request' && steps.plugins_branch_check.outputs.code == '0'
uses: actions/checkout@v4
with:
repository: smarthomeNG/plugins
ref: ${{ steps.extract_branch.outputs.branch }}
path: plugins
- name: Checkout plugins from branch 'develop' (pull request or push on unknown branch)
if: github.event_name == 'pull_request' || steps.plugins_branch_check.outputs.code == '2'
uses: actions/checkout@v4
with:
repository: smarthomeNG/plugins
ref: develop
path: plugins
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: security-and-quality
config: |
paths-ignore:
- '**/executor/examples/**'
# Autobuild is omitted — it is a no-op for Python (no compilation step needed).
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3