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

Godeepakm/add project flag #31

Merged
merged 6 commits into from
Feb 15, 2024
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
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ jobs:
with:
api-key: ${{secrets.fossaApiKey}}
branch: develop
project: custom-test-project

- name: Run FOSSA test with a --project and --branch
uses: ./
with:
api-key: ${{secrets.fossaApiKey}}
branch: develop
project: custom-test-project

- name: Run FOSSA test
uses: ./
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ jobs:
branch: some-feature-branch
```

### `project`

**Optional** Project flag passed to FOSSA CLI.

Example
```yml
jobs:
fossa-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: fossas/fossa-action@main # Use a specific version if locking is preferred
with:
api-key: ${{secrets.fossaApiKey}}
project: some-project-name
```

### `endpoint`

**Optional** Endpoint passed to FOSSA CLI. Defaults to `app.fossa.com`. [Read more](https://github.com/fossas/spectrometer/blob/master/docs/userguide.md#common-fossa-project-flags).
Expand Down Expand Up @@ -144,7 +161,7 @@ jobs:
```

### Running tests
This run `fossa tests` after doing an initial scan.
This runs `fossa tests` after doing an initial scan.

```yml
jobs:
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ 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
project:
description: >-
Override the detected FOSSA project name. 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
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ 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 PROJECT = getInput('project', getInputOptions());
export const DEBUG = getBooleanInput('debug', {required: false});
6 changes: 6 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,
PROJECT,
DEBUG,
} from './config';
import { fetchFossaCli } from './download-cli';
Expand All @@ -21,12 +22,17 @@ export async function analyze(): Promise<void> {
'--branch',
BRANCH,
];
const getProjectArgs = (): string[] => !PROJECT ? [] : [
'--project',
PROJECT,
];

const getArgs = (cmd: string) => [
CONTAINER ? 'container' : null,
cmd,
...getEndpointArgs(),
...getBranchArgs(),
...getProjectArgs(),
DEBUG ? '--debug' : null,
].filter(arg => arg);

Expand Down
Loading