Skip to content

Commit

Permalink
Allow the endpoint flag to be set
Browse files Browse the repository at this point in the history
Signed-off-by: Sora Morimoto <sora@morimoto.io>
  • Loading branch information
smorimoto committed Nov 13, 2021
1 parent 37eb19e commit 5352623
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to

## [unreleased]

- Allow the endpoint flag to be set.

## [1.1.5] - 2021-11-14

- Introduce changes for fossa cli v3.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
analysis.
- `github-token`: This input is used to get the latest release of `fossa-cli`
from GitHub API.
- `endpoint`: This input is used to specify which fossa endpoint to use.
- `skip-test`: This input is used to specify whether to execute
[`fossa test`](https://github.com/fossas/fossa-cli/blob/master/docs/user-guide.md/#fossa-test).
This takes a long time, so it's set to `true` by default.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ inputs:
fossa-api-key:
required: true
github-token:
required: false
default: ${{ github.token }}
endpoint:
required: false
skip-test:
required: false
default: true
runs:
using: node12
Expand Down
13 changes: 11 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15420,17 +15420,26 @@ var Platform;
})(Platform || (Platform = {}));
const FOSSA_API_KEY = core.getInput("fossa-api-key");
const GITHUB_TOKEN = core.getInput("github-token");
const ENDPOINT = core.getInput("endpoint");
const SKIP_TEST = core.getBooleanInput("skip-test");

;// CONCATENATED MODULE: ./src/analyze.ts


function getArgs() {
const args = [];
if (ENDPOINT) {
args.push(...["--endpoint", ENDPOINT]);
}
return args;
}
async function analyze() {
const args = getArgs();
const PATH = process.env.PATH || "";
const options = { env: { ...process.env, PATH, FOSSA_API_KEY: FOSSA_API_KEY } };
await (0,exec.exec)("fossa", ["analyze"], options);
await (0,exec.exec)("fossa", ["analyze", ...args], options);
if (!SKIP_TEST) {
await (0,exec.exec)("fossa", ["test"], options);
await (0,exec.exec)("fossa", ["test", ...args], options);
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/analyze.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import { exec } from "@actions/exec";

import { FOSSA_API_KEY, SKIP_TEST } from "./constants";
import { ENDPOINT, FOSSA_API_KEY, SKIP_TEST } from "./constants";

function getArgs() {
const args = [];
if (ENDPOINT) {
args.push(...["--endpoint", ENDPOINT]);
}
return args;
}

export async function analyze(): Promise<void> {
const args = getArgs();
const PATH = process.env.PATH || "";
const options = { env: { ...process.env, PATH, FOSSA_API_KEY } };
await exec("fossa", ["analyze"], options);
await exec("fossa", ["analyze", ...args], options);
if (!SKIP_TEST) {
await exec("fossa", ["test"], options);
await exec("fossa", ["test", ...args], options);
}
}
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ export const FOSSA_API_KEY = core.getInput("fossa-api-key");

export const GITHUB_TOKEN = core.getInput("github-token");

export const ENDPOINT = core.getInput("endpoint");

export const SKIP_TEST = core.getBooleanInput("skip-test");

0 comments on commit 5352623

Please sign in to comment.