Skip to content

Commit 47ef11b

Browse files
godeepakmrootcmbolingcsasarak
authored
Godeepakm/add project flag (#31)
* add prpject flag * add prpject flagcd * Build app * Add test for scanning with a --project option. * Run fossa test correctly. Oops. --------- Co-authored-by: root <root@ip-172-31-18-17.us-east-2.compute.internal> Co-authored-by: Chelsea Boling <chelsea@fossa.com> Co-authored-by: Christopher Sasarak <chris@fossa.com>
1 parent 32c7979 commit 47ef11b

7 files changed

Lines changed: 40 additions & 3 deletions

File tree

.github/workflows/test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ jobs:
5353
with:
5454
api-key: ${{secrets.fossaApiKey}}
5555
branch: develop
56+
project: custom-test-project
57+
58+
- name: Run FOSSA test with a --project and --branch
59+
uses: ./
60+
with:
61+
api-key: ${{secrets.fossaApiKey}}
62+
branch: develop
63+
project: custom-test-project
5664

5765
- name: Run FOSSA test
5866
uses: ./

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,23 @@ jobs:
8686
branch: some-feature-branch
8787
```
8888

89+
### `project`
90+
91+
**Optional** Project flag passed to FOSSA CLI.
92+
93+
Example
94+
```yml
95+
jobs:
96+
fossa-scan:
97+
runs-on: ubuntu-latest
98+
steps:
99+
- uses: actions/checkout@v3
100+
- uses: fossas/fossa-action@main # Use a specific version if locking is preferred
101+
with:
102+
api-key: ${{secrets.fossaApiKey}}
103+
project: some-project-name
104+
```
105+
89106
### `endpoint`
90107

91108
**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).
@@ -144,7 +161,7 @@ jobs:
144161
```
145162

146163
### Running tests
147-
This run `fossa tests` after doing an initial scan.
164+
This runs `fossa tests` after doing an initial scan.
148165

149166
```yml
150167
jobs:

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ inputs:
2424
Override the detected FOSSA project branch. If running FOSSA analysis on a
2525
Pull Request, as a start you can use the contexts `github.ref` or `github.ref_name`.
2626
required: false
27+
project:
28+
description: >-
29+
Override the detected FOSSA project name. If running FOSSA analysis on a
30+
Pull Request, as a start you can use the contexts `github.ref` or `github.ref_name`.
31+
required: false
2732
debug:
2833
description: >-
2934
Run all FOSSA commands in debug mode. Running `fossa analyze` in debug

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ export const CONTAINER = getInput('container', getInputOptions());
1212
export const RUN_TESTS = getBooleanInput('run-tests', {required: false});
1313
export const ENDPOINT = getInput('endpoint', getInputOptions());
1414
export const BRANCH = getInput('branch', getInputOptions());
15+
export const PROJECT = getInput('project', getInputOptions());
1516
export const DEBUG = getBooleanInput('debug', {required: false});

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
RUN_TESTS,
77
ENDPOINT,
88
BRANCH,
9+
PROJECT,
910
DEBUG,
1011
} from './config';
1112
import { fetchFossaCli } from './download-cli';
@@ -21,12 +22,17 @@ export async function analyze(): Promise<void> {
2122
'--branch',
2223
BRANCH,
2324
];
25+
const getProjectArgs = (): string[] => !PROJECT ? [] : [
26+
'--project',
27+
PROJECT,
28+
];
2429

2530
const getArgs = (cmd: string) => [
2631
CONTAINER ? 'container' : null,
2732
cmd,
2833
...getEndpointArgs(),
2934
...getBranchArgs(),
35+
...getProjectArgs(),
3036
DEBUG ? '--debug' : null,
3137
].filter(arg => arg);
3238

0 commit comments

Comments
 (0)