Skip to content

Commit 163a7c9

Browse files
author
Kevin Mack
committed
Fixing mapping of command
1 parent 8f6c3c6 commit 163a7c9

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

.github/workflows/codeql.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ jobs:
4949
- name: Stand up Devcontainer
5050
shell: bash
5151
run: |
52-
5352
devcontainer up --workspace-folder ${PWD} \
5453
--workspace-mount-consistency cached \
5554
--id-label devcontainer.local_folder=${PWD} \
@@ -60,26 +59,39 @@ jobs:
6059
--update-remote-user-uid-default on \
6160
--mount-workspace-git-root true
6261
echo $?
63-
62+
6463
- name: install-codeql
6564
shell: bash
6665
run: |
67-
echo "Determine the latest release version of CodeQL CLI"
68-
docker exec hostsvc-link bash -c "LATEST_RELEASE=$(curl -s https://api.github.com/repos/github/codeql-cli-binaries/releases/latest | grep \"tag_name\" | awk '{print substr($2, 2, length($2)-3)}')"
66+
CONTAINER_NAME="hostsvc-link"
6967
70-
echo "Create target directory if it doesn't exist"
71-
docker exec hostsvc-link bash -c "mkdir -p \"${{ github.workspace }}/codeql\""
68+
# Determine the latest release version of CodeQL CLI
69+
docker exec $CONTAINER_NAME bash -c "curl -s https://api.github.com/repos/github/codeql-cli-binaries/releases/latest | grep 'tag_name' | awk '{print substr(\$2, 2, length(\$2)-3)}'" > latest_release.txt
70+
LATEST_RELEASE=$(<latest_release.txt)
7271
73-
echo "Download the latest release of CodeQL CLI"
72+
# Define the download URL and target directory
73+
DOWNLOAD_URL="https://github.com/github/codeql-cli-binaries/releases/download/${LATEST_RELEASE}/codeql-linux64.zip"
74+
TARGET_DIR="/root/codeql" # Adjust the target directory as per the container's file system
75+
ZIP_FILE="$TARGET_DIR/codeql.zip"
76+
77+
# Create target directory if it doesn't exist
78+
docker exec $CONTAINER_NAME bash -c "mkdir -p $TARGET_DIR"
79+
80+
# Download the latest release of CodeQL CLI
7481
echo "Downloading CodeQL CLI ${LATEST_RELEASE}..."
75-
docker exec hostsvc-link bash -c "curl -L \"https://github.com/github/codeql-cli-binaries/releases/download/${LATEST_RELEASE}/codeql-linux64.zip\" -o \"${{ github.workspace }}/codeql/codeql.zip\""
82+
docker exec $CONTAINER_NAME bash -c "curl -L '$DOWNLOAD_URL' -o '$ZIP_FILE'"
7683
77-
echo "Extract the downloaded zip file"
84+
# Extract the downloaded zip file
7885
echo "Extracting CodeQL CLI..."
79-
docker exec hostsvc-link bash -c "unzip -o \"${{ github.workspace }}/codeql/codeql.zip\" -d \"${{ github.workspace }}/codeql\""
86+
docker exec $CONTAINER_NAME bash -c "unzip -o '$ZIP_FILE' -d '$TARGET_DIR'"
87+
88+
# Clean up the zip file
89+
docker exec $CONTAINER_NAME bash -c "rm '$ZIP_FILE'"
8090
81-
echo "Clean up the zip file"
82-
docker exec hostsvc-link bash -c "rm \"${{ github.workspace }}/codeql/codeql.zip\""
91+
# Optionally, add CodeQL CLI to PATH by adding it to .bashrc or .bash_profile
92+
# Note: This step might need adjustments based on the container's shell configuration
93+
docker exec $CONTAINER_NAME bash -c "echo 'export PATH=\$PATH:$TARGET_DIR/codeql' >> /root/.bashrc"
94+
docker exec $CONTAINER_NAME bash -c "source /root/.bashrc"
8395
8496
echo "CodeQL CLI installation completed."
8597

0 commit comments

Comments
 (0)