Skip to content

Commit 2309ce2

Browse files
committed
fix: Set if statements to control CodeQL workflow
Signed-off-by: Gabryel Nóbrega <gabryelster@gmail.com>
1 parent fad6173 commit 2309ce2

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

.github/workflows/codeql.yml

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
# You may wish to alter this file to override the set of languages analyzed,
55
# or to provide custom queries or build logic.
66
#
7-
# ******** NOTE ********
8-
# We have attempted to detect the languages in your repository. Please check
9-
# the `language` matrix defined below to confirm you have the correct set of
10-
# supported CodeQL languages.
11-
#
127
name: "CodeQL Advanced"
138

149
on:
@@ -27,7 +22,6 @@ jobs:
2722
# - https://gh.io/supported-runners-and-hardware-resources
2823
# - https://gh.io/using-larger-runners (GitHub.com only)
2924
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
30-
3125
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
3226
permissions:
3327
# required for all workflows
@@ -50,9 +44,9 @@ jobs:
5044
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
5145
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
5246
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
53-
matrix:
54-
language: [ 'python', 'javascript-typescript', '' ] # Define your languages here
5547

48+
# matrix:
49+
# include:
5650
steps:
5751
- name: Checkout repository
5852
uses: actions/checkout@v4
@@ -63,12 +57,22 @@ jobs:
6357
# - name: Setup runtime (example)
6458
# uses: actions/setup-example@v1
6559

60+
- name: Check if language is set
61+
if: ${{ matrix.language == '' }}
62+
run: |
63+
echo "::warning::No language detected. Skipping analysis."
64+
65+
- name: Cancel Workflow
66+
if: ${{ matrix.language == '' }}
67+
uses: andymckay/cancel-action@0.4
68+
6669
# Initializes the CodeQL tools for scanning.
6770
- name: Initialize CodeQL
71+
if: ${{ matrix.language != '' }}
6872
uses: github/codeql-action/init@v3
6973
with:
7074
languages: ${{ matrix.language }}
71-
# build-mode: ${{ matrix.build-mode }}
75+
build-mode: ${{ matrix.build-mode }}
7276
# If you wish to specify custom queries, you can do so here or in a config file.
7377
# By default, queries listed here will override any specified in a config file.
7478
# Prefix the list here with "+" to use these queries and those in the config file.
@@ -82,17 +86,18 @@ jobs:
8286
# to build your code.
8387
# ℹ️ Command-line programs to run using the OS shell.
8488
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
85-
# - if: matrix.build-mode == 'manual'
86-
# shell: bash
87-
# run: |
88-
# echo 'If you are using a "manual" build mode for one or more of the' \
89-
# 'languages you are analyzing, replace this with the commands to build' \
90-
# 'your code, for example:'
91-
# echo ' make bootstrap'
92-
# echo ' make release'
93-
# exit 1
89+
- if: ${{ matrix.build-mode == 'manual' }}
90+
shell: bash
91+
run: |
92+
echo 'If you are using a "manual" build mode for one or more of the' \
93+
'languages you are analyzing, replace this with the commands to build' \
94+
'your code, for example:'
95+
echo ' make bootstrap'
96+
echo ' make release'
97+
exit 1
9498
9599
- name: Perform CodeQL Analysis
100+
if: ${{ matrix.language != '' }}
96101
uses: github/codeql-action/analyze@v3
97102
with:
98-
category: "/language:${{matrix.language}}"
103+
category: "/language:${{ matrix.language }}"

0 commit comments

Comments
 (0)