Skip to content

Commit c16e6d0

Browse files
authored
feat: refactor GitHub Action to use published npm package via npx (#687)
- Remove npm ci and build steps; use npx cve-lite-cli@version instead - Add version input (default: 1) to pin to latest 1.x release - Add major version check that warns when a newer major is available Closes #686
1 parent df10e26 commit c16e6d0

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

action.yml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ inputs:
6767
description: "Path to a PEM CA certificate file for corporate SSL inspection proxies"
6868
required: false
6969
default: ""
70+
version:
71+
description: "CVE Lite CLI version to install (e.g. '1.23.1', '1', 'latest')"
72+
required: false
73+
default: "1"
7074

7175
runs:
7276
using: "composite"
@@ -76,15 +80,18 @@ runs:
7680
with:
7781
node-version: ${{ inputs.node-version }}
7882

79-
- name: Install CVE Lite CLI dependencies
80-
shell: bash
81-
working-directory: ${{ github.action_path }}
82-
run: npm ci
83-
84-
- name: Build CVE Lite CLI
83+
- name: Check for new major version
8584
shell: bash
86-
working-directory: ${{ github.action_path }}
87-
run: npm run build
85+
env:
86+
INPUT_VERSION: ${{ inputs.version }}
87+
run: |
88+
LATEST=$(npm view cve-lite-cli version 2>/dev/null || echo "")
89+
if [[ -z "$LATEST" || "$INPUT_VERSION" == "latest" ]]; then exit 0; fi
90+
CURRENT_MAJOR="${INPUT_VERSION%%.*}"
91+
LATEST_MAJOR="${LATEST%%.*}"
92+
if [[ "$LATEST_MAJOR" -gt "$CURRENT_MAJOR" ]]; then
93+
echo "::warning::CVE Lite CLI v${LATEST_MAJOR} is available. You are currently using v${CURRENT_MAJOR}.x. Update the 'version' input in your workflow to upgrade."
94+
fi
8895
8996
- name: Resolve action inputs
9097
id: resolve
@@ -118,7 +125,7 @@ runs:
118125
shell: bash
119126
working-directory: ${{ github.workspace }}
120127
env:
121-
ACTION_PATH: ${{ github.action_path }}
128+
INPUT_VERSION: ${{ inputs.version }}
122129
OFFLINE_DB_PATH: ${{ steps.resolve.outputs.offline-db }}
123130
INPUT_CA_CERT: ${{ inputs.ca-cert }}
124131
run: |
@@ -128,13 +135,13 @@ runs:
128135
if [[ -n "${INPUT_CA_CERT}" ]]; then
129136
sync_args+=("--ca-cert" "${INPUT_CA_CERT}")
130137
fi
131-
node "${ACTION_PATH}/dist/index.js" "${sync_args[@]}"
138+
npx --yes "cve-lite-cli@${INPUT_VERSION}" "${sync_args[@]}"
132139
133140
- name: Run CVE Lite CLI scan
134141
shell: bash
135142
working-directory: ${{ github.workspace }}
136143
env:
137-
ACTION_PATH: ${{ github.action_path }}
144+
INPUT_VERSION: ${{ inputs.version }}
138145
PROJECT_PATH: ${{ steps.resolve.outputs.project-path }}
139146
USE_OFFLINE: ${{ steps.resolve.outputs.use-offline }}
140147
OFFLINE_DB_PATH: ${{ steps.resolve.outputs.offline-db }}
@@ -195,4 +202,4 @@ runs:
195202
args+=("--ca-cert" "${INPUT_CA_CERT}")
196203
fi
197204
198-
node "${ACTION_PATH}/dist/index.js" "${args[@]}"
205+
npx --yes "cve-lite-cli@${INPUT_VERSION}" "${args[@]}"

0 commit comments

Comments
 (0)