Skip to content

Commit ccf9fa4

Browse files
ConXPanquesito7
andauthored
Fix the CodeQL workflow to run only on .github (#1767)
* Update codeql-analysis to run on .github * Update .github/workflows/codeql-analysis.yml Co-authored-by: David Leal <halfpacho@gmail.com> --------- Co-authored-by: David Leal <halfpacho@gmail.com>
1 parent 60b8436 commit ccf9fa4

1 file changed

Lines changed: 56 additions & 32 deletions

File tree

.github/workflows/codeql-analysis.yml

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,80 @@ on:
66
pull_request:
77
branches: [master, develop]
88
schedule:
9-
# ┌───────────── minute (0 - 59)
10-
# │ ┌───────────── hour (0 - 23)
11-
# │ │ ┌───────────── day of the month (1 - 31)
12-
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
13-
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
14-
# │ │ │ │ │
15-
# │ │ │ │ │
16-
# │ │ │ │ │
17-
# * * * * *
18-
- cron: '30 1 * * 0'
9+
- cron: 30 1 * * 0 # Runs every Sunday 1:30 am UTC
1910

2011
jobs:
21-
CodeQL-Build:
22-
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
12+
CodeQL-Javascript:
2313
runs-on: ubuntu-latest
24-
2514
permissions:
26-
# required for all workflows
2715
security-events: write
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
20+
- name: Initialize CodeQL
21+
uses: github/codeql-action/init@v2
22+
with:
23+
languages: javascript
2824

29-
# only required for workflows in private repositories
30-
actions: read
31-
contents: read
25+
- name: Perform CodeQL Analysis
26+
uses: github/codeql-action/analyze@v2
3227

28+
CodeQL-Python-dot-github:
29+
runs-on: ubuntu-latest
30+
permissions:
31+
security-events: write
3332
steps:
3433
- name: Checkout repository
3534
uses: actions/checkout@v3
3635

37-
# Initializes the CodeQL tools for scanning.
36+
- name: Set up Python
37+
uses: actions/setup-python@v4
38+
id: setup-python
39+
with:
40+
python-version: '3.10'
41+
42+
- name: Install dependencies
43+
run: |
44+
python -m pip install --upgrade pip
45+
if [ -f ${{ github.workspace }}/.github/scripts/requirements.txt ];
46+
then pip install -r ${{ github.workspace }}/.github/scripts/requirements.txt;
47+
fi
48+
# Set the `CODEQL-PYTHON` environment variable to the Python executable
49+
# that includes the dependencies
50+
echo "CODEQL_PYTHON=${{ steps.setup-python.outputs.python-path }}" >> $GITHUB_ENV
51+
3852
- name: Initialize CodeQL
3953
uses: github/codeql-action/init@v2
40-
# Override language selection by uncommenting this and choosing your languages
4154
with:
42-
languages: javascript, python
55+
languages: python
56+
setup-python-dependencies: false
57+
source-root: .github/
4358

44-
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
45-
# If this step fails, then you should remove it and run the build manually (see below).
46-
- name: Autobuild
47-
uses: github/codeql-action/autobuild@v2
59+
- name: Perform CodeQL Analysis
60+
uses: github/codeql-action/analyze@v2
4861

49-
# ℹ️ Command-line programs to run using the OS shell.
50-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
62+
CodeQL-Python-rest:
63+
runs-on: ubuntu-latest
64+
permissions:
65+
security-events: write
66+
steps:
67+
- name: Checkout repository
68+
uses: actions/checkout@v3
5169

52-
# ✏️ If the Autobuild fails above, remove it and uncomment the following
53-
# three lines and modify them (or add more) to build your code if your
54-
# project uses a compiled language
70+
- name: Find Python files outside the .github folder
71+
id: find_files
72+
run: |
73+
python_files=$(find ${{ github.workspace }} -name "*.py" -type f -not -path '*/\.*' | wc -l)
74+
echo "python_files=${python_files}" >> $GITHUB_OUTPUT
75+
echo "$python_files Python files were found outside the .github folder."
5576
56-
#- run: |
57-
# make bootstrap
58-
# make release
77+
- name: Initialize CodeQL
78+
if: ${{ steps.find_files.outputs.python_files != '0' }}
79+
uses: github/codeql-action/init@v2
80+
with:
81+
languages: python
5982

6083
- name: Perform CodeQL Analysis
84+
if: ${{ steps.find_files.outputs.python_files != '0' }}
6185
uses: github/codeql-action/analyze@v2

0 commit comments

Comments
 (0)