Skip to content

Commit ce54456

Browse files
committed
feat(ci): Add config script and update workflow
1 parent 11dbd3f commit ce54456

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

.github/scripts/pr-configs.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
PR_NUMBER=${1}
5+
6+
codeql_db="/tmp/codeql-test-database"
7+
8+
for file in $(gh pr view $PR_NUMBER --json files --jq '.files.[].path'); do
9+
if [[ ! -f "$file" ]]; then
10+
continue
11+
fi
12+
13+
# config file
14+
if [[ "$file" == configs/*.yml ]]; then
15+
echo "[+] Compiling Config :: $file"
16+
17+
if [[ -d "$codeql_db" ]]; then
18+
rm -rf "$codeql_db"
19+
fi
20+
21+
gh codeql database create \
22+
--source-root=./.github/scripts \
23+
--language=python \
24+
--codescanning-config=$file \
25+
"$codeql_db"
26+
fi
27+
done

.github/workflows/build.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,25 @@ jobs:
141141
codeql pack install "${{ matrix.language }}/ext-library-sources/"
142142
codeql pack create "${{ matrix.language }}/ext-library-sources/"
143143
144+
configs:
145+
runs-on: ubuntu-latest
146+
needs: compile
147+
148+
steps:
149+
- uses: actions/checkout@v3
150+
151+
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50
152+
id: changes
153+
with:
154+
filters: |
155+
src:
156+
- 'configs/**'
157+
158+
- name: "Check Configurations"
159+
if: steps.changes.outputs.src == 'true'
160+
env:
161+
GITHUB_TOKEN: ${{ github.token }}
162+
run: |
163+
./.github/scripts/pr-configs.sh "${{ github.event.number }}"
164+
165+

0 commit comments

Comments
 (0)