-
Notifications
You must be signed in to change notification settings - Fork 8
91 lines (84 loc) · 3.31 KB
/
Copy pathcodeql.yml
File metadata and controls
91 lines (84 loc) · 3.31 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
---
name: CodeQL
on: # yamllint disable-line rule:truthy
workflow_call:
inputs:
requested:
description: Run this workflow for an authorized /citest command
required: true
type: boolean
schedule:
- cron: 4 3 * * 2
permissions:
contents: read
pull-requests: read
# This is required for the ability to create/update the Pull request status
statuses: write
jobs:
analyze:
if: inputs.requested || github.event_name != 'issue_comment'
name: Analyze
runs-on: ubuntu-latest
permissions:
pull-requests: read
actions: read
contents: read
security-events: write
statuses: write
strategy:
fail-fast: false
matrix:
language: [python]
steps:
- name: Get PR head SHA and context
if: github.event_name == 'issue_comment'
id: head_sha_context
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.issue.number }}
CONTEXT: "${{ github.workflow }} / Analyze (${{ matrix.language }}) (pull_request)"
run: |
set -euxo pipefail
head_sha=$(gh api "repos/$REPO/pulls/$PR_NUMBER" --jq '.head.sha')
echo "head_sha=$head_sha" >> "$GITHUB_OUTPUT"
echo "context=$CONTEXT" >> "$GITHUB_OUTPUT"
- name: Set commit status as pending
if: github.event_name == 'issue_comment'
uses: myrotvorets/set-commit-status-action@c0f880c99d91381c6fdb97726f03feb8004409b4 # master
with:
sha: ${{ steps.head_sha_context.outputs.head_sha }}
status: pending
context: ${{ steps.head_sha_context.outputs.context }}
description: Test started
targetUrl: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ job.check_run_id }}
- name: Update pip, git
run: |
set -euxo pipefail
sudo apt update
sudo apt install -y git
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
ref: ${{ steps.head_sha_context.outputs.head_sha || github.sha }}
- name: Initialize CodeQL
uses: github/codeql-action/init@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
- name: Autobuild
uses: github/codeql-action/autobuild@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9
with:
category: "/language:${{ matrix.language }}"
- name: Set final commit status
if: always() && github.event_name == 'issue_comment' && steps.head_sha_context.outputs.head_sha != ''
uses: myrotvorets/set-commit-status-action@c0f880c99d91381c6fdb97726f03feb8004409b4 # master
with:
sha: ${{ steps.head_sha_context.outputs.head_sha }}
status: ${{ job.status }}
context: ${{ steps.head_sha_context.outputs.context }}
description: Test finished
targetUrl: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ job.check_run_id }}