Skip to content

Commit 4f7c484

Browse files
authored
Add schedule for running CodeQL scan (#4054)
1 parent 9cfa99b commit 4f7c484

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ on:
4545
- 'archive/r/ruby/*.rb'
4646
- 'archive/s/swift/*.swift'
4747
- 'archive/t/typescript/*.ts'
48+
schedule:
49+
# Run every Thursday at 4:53 UTC (randomly chosen)
50+
- cron: '53 4 * * 6'
4851

4952
jobs:
5053
# We need this job to check if changed files should trigger analysis
@@ -77,7 +80,7 @@ jobs:
7780
- name: Get CodeQL Languages
7881
id: set-matrix
7982
run: |
80-
matrix=$(python scripts/get_codeql_languages.py ${{ steps.changed-files.outputs.all_changed_files }})
83+
matrix=$(python scripts/get_codeql_languages.py --event ${{ github.event_name}} ${{ steps.changed-files.outputs.all_changed_files }})
8184
echo "${matrix}"
8285
echo "matrix={\"include\": ${matrix}}" >> $GITHUB_OUTPUT
8386

scripts/get_codeql_languages.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@ class LanguageInfo:
4040

4141
def main():
4242
parser = argparse.ArgumentParser()
43+
parser.add_argument("--event", help="GitHub event")
4344
parser.add_argument("files_changed", nargs="*", help="files that have changed")
4445
parsed_args = parser.parse_args()
4546
languages: Set[LanguageInfo] = set()
4647
language_paths: DefaultDict[str, Set[str]] = defaultdict(set)
4748
language_paths_ignore: DefaultDict[str, Set[str]] = defaultdict(set)
48-
if set(parsed_args.files_changed) & ALL_CODEQL_LANGUAGES_FILES:
49+
if (
50+
parsed_args.event == "schedule"
51+
or set(parsed_args.files_changed) & ALL_CODEQL_LANGUAGES_FILES
52+
):
4953
for glob, language_info in CODEQL_LANGUAGES.items():
5054
languages.add(language_info)
5155
language_paths[language_info.language].add(glob)

0 commit comments

Comments
 (0)