Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,22 @@ The Setup Action requires `bash` and `curl` to be available and requires privile
The Snyk Setup Action has properties which are passed to the underlying image. These are
passed to the action using `with`.

| Property | Default | Description |
| --- | --- | --- |
| snyk-version | latest | Install a specific version of Snyk |
| Property | Default | Description |
|--------------|---------|------------------------------------|
| snyk-version | latest | Install a specific version of Snyk |

The Action also has outputs:

| Property | Default | Description |
| --- | --- | --- |
| version | | The full version of the Snyk CLI installed |
| Property | Default | Description |
|----------|---------|--------------------------------------------|
| version | | The full version of the Snyk CLI installed |

## Caching

The Setup Action automatically caches the Snyk CLI binary to speed up subsequent workflow runs. The cache key is based on the operating system and Snyk version (`snyk-{os}-{version}`).

> [!IMPORTANT]
> The Snyk CLI is only cached when using a specific version of Snyk (e.g., `v1.391.0`). When using `snyk-version: latest`, the CLI will always be re-downloaded to ensure you have the most recent version.

For example, you can choose to install a specific version of Snyk. The installed version can be
grabbed from the output:
Expand Down
24 changes: 17 additions & 7 deletions setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,25 @@ outputs:
runs:
using: "composite"
steps:
- env:
- name: Cache Snyk CLI
id: cache-snyk
uses: actions/cache@v4
with:
path: |
/usr/local/bin/snyk
/usr/local/bin/snyk-*
key: snyk-${{ inputs.os }}-${{ inputs.snyk-version }}

- name: Install Snyk CLI
if: inputs.snyk-version == 'latest' || steps.cache-snyk.outputs.cache-hit != 'true'
shell: bash
env:
INPUT_SNYK_VERSION: ${{ inputs.snyk-version }}
INPUT_OS: ${{ inputs.os }}
run: |
echo $GITHUB_ACTION_PATH
echo ${{ github.action_path }}

${{ github.action_path }}/setup_snyk.sh "${INPUT_SNYK_VERSION}" "${INPUT_OS}" || $GITHUB_ACTION_PATH/setup_snyk.sh "${INPUT_SNYK_VERSION}" "${INPUT_OS}"

- name: Get Snyk version
id: version
shell: bash
- id: version
shell: bash
run: echo "version=$(snyk version)" >> $GITHUB_OUTPUT
run: echo "version=$(snyk version)" >> "${GITHUB_OUTPUT}"