-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathaction.yml
More file actions
62 lines (53 loc) · 2.12 KB
/
action.yml
File metadata and controls
62 lines (53 loc) · 2.12 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
name: Setup CodeQL CLI
description: |
Install a CodeQL CLI or re-use an existing one from the cache and it to the path.
outputs:
codeql-cli-version:
description: "The version of the CodeQL CLI that was installed or retrieved from cache"
value: ${{ steps.codeql-version.outputs.codeql-cli-version }}
runs:
using: composite
steps:
- name: "CodeQL Version"
id: codeql-version
shell: bash
run: |
echo "Reading CodeQL CLI version from .codeqlversion file."
CODEQL_CLI_VERSION=$(cat ./.codeqlversion)
echo "CODEQL_CLI_VERSION=${CODEQL_CLI_VERSION}" >> $GITHUB_ENV
echo "codeql-cli-version=${CODEQL_CLI_VERSION}" >> $GITHUB_OUTPUT
- name: Cache CodeQL
id: cache-codeql
uses: actions/cache@v4
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ${{github.workspace}}/codeql_home
# An explicit key for restoring and saving the cache
key: codeql-home-${{ steps.codeql-version.outputs.codeql-cli-version }}
- name: Install CodeQL
id: install-codeql
if: steps.cache-codeql.outputs.cache-hit != 'true'
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
CODEQL_HOME: ${{ github.workspace }}/codeql_home
CODEQL_CLI_VERSION: ${{ steps.codeql-version.outputs.codeql-cli-version }}
run: |
echo "Installing CodeQL CLI v${CODEQL_CLI_VERSION}."
mkdir -p $CODEQL_HOME
echo "Change directory to $CODEQL_HOME"
pushd $CODEQL_HOME
echo "Downloading CodeQL CLI v${CODEQL_CLI_VERSION}."
gh release download "v${CODEQL_CLI_VERSION}" --repo https://github.com/github/codeql-cli-binaries --pattern codeql-linux64.zip
echo "Unzipping CodeQL CLI."
unzip -q codeql-linux64.zip
popd
echo "Done."
echo "codeql-cli-version=${CODEQL_CLI_VERSION}" >> $GITHUB_OUTPUT
- name: Add CodeQL to the PATH
shell: bash
env:
CODEQL_HOME: ${{ github.workspace }}/codeql_home
run: |
echo "Adding CodeQL CLI to the PATH."
echo "$CODEQL_HOME/codeql" >> $GITHUB_PATH