Skip to content

Commit

Permalink
Add debug mode option
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo López Dato committed Oct 6, 2022
1 parent f61a4c0 commit bb9242c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,17 @@ jobs:
- name: Build
run: yarn build

- name: Run FOSSA scan and upload build data
- name: Run FOSSA scan in debug mode and upload build data
uses: ./
with:
api-key: ${{secrets.fossaApiKey}}
debug: true

- name: Upload FOSSA debug bundle as a build artifact
uses: actions/upload-artifact@v3
with:
name: fossa.debug.json.gz
path: ./fossa.debug.json.gz

- name: Run FOSSA container scan and upload build data
uses: ./
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,29 @@ jobs:
endpoint: fossa.my-company.com
```

### `debug`

**Optional** If set to `true`, run all FOSSA commands in debug mode. Running `fossa analyze` in debug mode will generate a debug bundle that can be uploaded as a build artifact after this action completes.

One way to upload build artifacts is to use the `upload-artifact` GitHub action. Example:

```yml
jobs:
fossa-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: fossas/fossa-action@main
with:
api-key: ${{secrets.fossaApiKey}}
debug: true
- uses: actions/upload-artifact@v3
with:
name: fossa.debug.json.gz
path: ./fossa.debug.json.gz
```


## Examples
We've provided a few examples of how to use FOSSA's Github Action in your own project. These examples use an API key stored as a Github secret environment variable `fossaAPiKey`.

Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ inputs:
Override the detected FOSSA project branch. If running FOSSA analysis on a
Pull Request, as a start you can use the contexts `github.ref` or `github.ref_name`.
required: false
debug:
description: >-
Run all FOSSA commands in debug mode. Running `fossa analyze` in debug
mode will generate a debug bundle that can be uploaded as a build artifact
after this action completes.
default: false

runs:
using: node16
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export const CONTAINER = getInput('container', getInputOptions());
export const RUN_TESTS = getBooleanInput('run-tests', {required: false});
export const ENDPOINT = getInput('endpoint', getInputOptions());
export const BRANCH = getInput('branch', getInputOptions());
export const DEBUG = getBooleanInput('debug', {required: false});
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
RUN_TESTS,
ENDPOINT,
BRANCH,
DEBUG,
} from './config';
import { fetchFossaCli } from './download-cli';

Expand All @@ -26,6 +27,7 @@ export async function analyze(): Promise<void> {
cmd,
...getEndpointArgs(),
...getBranchArgs(),
DEBUG ? '--debug' : null,
].filter(arg => arg);

// Setup listeners
Expand Down

0 comments on commit bb9242c

Please sign in to comment.