Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Convert Nexus IQ reusable workflow to an action #207

Merged
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
50 changes: 50 additions & 0 deletions .github/actions/sonatype-lifecycle-action/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!--
[comment]: # SPDX-License-Identifier: Apache-2.0
[comment]: # SPDX-FileCopyrightText: 2024 The Linux Foundation
-->

# 🎟️ Performs a Sonatype Lifecycle (Nexus IQ) Scan

Performs a Sonatype Lifecycle scan and uploads the results to the server.

## sonatype-lifecycle-action

## Usage Example

Pass the required server and authentication details/credentials.
Other inputs are discretionary and set to useful defaults.

```yaml
steps:
- name: "Run Sonatype Lifecycle scan"
# yamllint disable-line rule:line-length
uses: lfit/releng-reusable-workflows/.github/actions/sonatype-lifecycle-action@main
with:
NEXUS_IQ_SERVER: "${{ vars.NEXUS_IQ_SERVER }}"
NEXUS_IQ_USERNAME: "${{ vars.NEXUS_IQ_USERNAME }}"
NEXUS_IQ_PASSWORD: "${{ secrets.NEXUS_IQ_PASSWORD }}"
```

## Inputs

<!-- markdownlint-disable MD013 -->

| Variable Name | Required | Default | Description |
| ----------------- | -------- | ------------ | ------------------------------------------- |
| NEXUS_IQ_SERVER | True | N/A | JSON array of key/value pairs |
| NEXUS_IQ_USERNAME | True | N/A | Fixed preamble/string to embed/inject |
| NEXUS_IQ_PASSWORD | True | N/A | When set false, checks for presence |
| JAVA_DISTRIBUTION | False | "temurin" | JAVA SE distribution for the Nexus CLI tool |
| JAVA_VERSION | False | 17 | Java runtime for the Nexus CLI tool |
| IQ_CLI_VERSION | False | "1.179.0-01" | Specific version of Nexus CLI to setup/run |
| APPLICATION_ID | False | $org-$repo | Organisation and project name in Nexus IQ |
| SCAN_TARGETS | False | "." | Location of file(s) or folder(s) to scan |

<!-- markdownlint-enable MD013 -->

The APPLICATION_ID default is:

`${{ github.repository_owner }}-${{ github.event.repository.name }}`

Note: when testing in a fork this must be manually overridden for report
uploads to succeed.
68 changes: 68 additions & 0 deletions .github/actions/sonatype-lifecycle-action/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2024 The Linux Foundation

# Runs a Sonatype Lifecycle (Nexus IQ) scan
name: "Sonatype Lifecycle Action"

inputs:
# Required
NEXUS_IQ_SERVER:
description: "Nexus IQ Server"
required: true
NEXUS_IQ_USERNAME:
description: "Nexus IQ Username"
required: true
NEXUS_IQ_PASSWORD:
description: "Nexus IQ Password"
required: true
# Optional
JAVA_DISTRIBUTION:
description: "JAVA SE distribution to setup/run for Nexus CLI tool"
required: false
type: string
default: "temurin"
JAVA_VERSION:
description: "Java runtime to setup/run for Nexus CLI tool"
required: false
type: number
default: 17
IQ_CLI_VERSION:
description: "Specific version of Nexus CLI to setup/run"
required: false
type: string
default: "1.179.0-01"
APPLICATION_ID:
description: "Organisation and project name in Nexus IQ"
required: false
type: string
default: ${{ github.repository_owner }}-${{ github.event.repository.name }}
SCAN_TARGETS:
description: "Location of file(s) or folder(s) to scan"
required: false
type: string
default: "."

runs:
using: "composite"
steps:
- name: Setup Sonatype CLI
uses: sonatype/actions/setup-iq-cli@v1
with:
iq-cli-version: ${{ inputs.IQ_CLI_VERSION }}

# Sonatype CLI requires Java to run
- name: Setup Java runtime
uses: actions/setup-java@v4
with:
distribution: ${{ inputs.JAVA_DISTRIBUTION }}
java-version: ${{ inputs.JAVA_VERSION }}

- name: Run Sonatype CLI
uses: sonatype/actions/run-iq-cli@v1
with:
iq-server-url: ${{ inputs.NEXUS_IQ_SERVER }}
username: ${{ inputs.NEXUS_IQ_USERNAME }}
password: ${{ inputs.NEXUS_IQ_PASSWORD }}
application-id: ${{ inputs.APPLICATION_ID }}
scan-targets: ${{ inputs.SCAN_TARGETS }}
Loading