-
Notifications
You must be signed in to change notification settings - Fork 1
116 lines (99 loc) · 3.55 KB
/
codeql.yml
File metadata and controls
116 lines (99 loc) · 3.55 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# This workflow is a required merge check on `dev`. The exact ruleset
# entry to register is `codeql / analyze-js-ts`. PawWork runs user-
# authored skills and accesses the OS keychain; solo-dev code review is
# not a substitute for a JS/TS security scanner. Keep it in its own file
# (not folded into ci.yml) so security failures are legible in isolation.
# Decision recorded in issue #54 (D1).
name: codeql
on:
push:
branches: [dev]
pull_request:
branches: [dev]
schedule:
- cron: "0 2 * * 1"
permissions:
actions: read
contents: read
security-events: write
concurrency:
group: codeql-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
runs-on: ubuntu-latest
outputs:
docs_only: ${{ steps.filter.outputs.docs_only }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- id: filter
env:
EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
HEAD_SHA: ${{ github.sha }}
run: |
set -euo pipefail
is_docs_path() {
case "$1" in
README.md|README_CN.md|assets/readme/*|.github/ISSUE_TEMPLATE/*|.github/pull_request_template.md|packages/*/README.md|packages/opencode/specs/*|packages/opencode/BUN_SHELL_MIGRATION_PLAN.md|packages/app/create-effect-simplification-spec.md)
return 0
;;
*)
return 1
;;
esac
}
docs_only=false
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
echo "docs_only=false" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ -z "$BASE_SHA" ] || [ "$BASE_SHA" = "0000000000000000000000000000000000000000" ]; then
BASE_SHA="$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
mapfile -t changes < <(git diff --name-status --find-renames --find-copies "$BASE_SHA" "$HEAD_SHA" --)
if [ "${#changes[@]}" -gt 0 ]; then
docs_only=true
for change in "${changes[@]}"; do
IFS=$'\t' read -r status path1 path2 <<< "$change"
case "$status" in
A*|M*|T*|D*)
if ! is_docs_path "$path1"; then
docs_only=false
break
fi
;;
R*|C*)
if ! is_docs_path "$path1" || ! is_docs_path "$path2"; then
docs_only=false
break
fi
;;
*)
docs_only=false
break
;;
esac
done
fi
echo "docs_only=$docs_only" >> "$GITHUB_OUTPUT"
analyze-js-ts:
needs: changes
if: needs.changes.outputs.docs_only != 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # actions/checkout@v6
with:
persist-credentials: false
- name: Initialize CodeQL
uses: github/codeql-action/init@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # github/codeql-action@v4
with:
languages: javascript-typescript
- name: Analyze with CodeQL
uses: github/codeql-action/analyze@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # github/codeql-action@v4
with:
category: "/language:javascript-typescript"