-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (75 loc) · 2.59 KB
/
Copy pathcodeql.yml
File metadata and controls
83 lines (75 loc) · 2.59 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
name: CodeQL
on:
workflow_call:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "17 6 * * 2"
workflow_dispatch:
permissions: {}
concurrency:
group: codeql-${{ github.event.pull_request.head.ref || github.ref }}
cancel-in-progress: true
jobs:
analyze:
name: Analyze ${{ matrix.language }}
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [javascript-typescript, ruby]
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Initialize CodeQL
uses: github/codeql-action/init@db488ddef3bf6cb639b32c2e9a7c0a7ea8271d28 # v4.37.8
with:
languages: ${{ matrix.language }}
build-mode: none
queries: security-extended
- name: Analyze repository
uses: github/codeql-action/analyze@db488ddef3bf6cb639b32c2e9a7c0a7ea8271d28 # v4.37.8
with:
category: /language:${{ matrix.language }}
status:
name: Report the dispatched run on its commit
if: ${{ always() && github.event_name == 'workflow_dispatch' }}
needs: [analyze]
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
statuses: write
steps:
- name: Post a commit status
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const passed = ${{ toJSON(needs.analyze.result) }} === 'success';
const targetUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
// A reusable-workflow dispatch prefixes matrix check names with the
// caller job. Publish the same canonical contexts as a normal PR so
// generated PRs satisfy the repository's required-status rules.
for (const statusContext of [
'Analyze javascript-typescript',
'Analyze ruby',
'CodeQL (dispatch)',
]) {
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: passed ? 'success' : 'failure',
context: statusContext,
target_url: targetUrl,
description: passed ? 'CodeQL passed' : 'CodeQL reported problems',
});
}