Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
austenstone committed Aug 22, 2022
1 parent 26ff8d4 commit 3e793a7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ inputs:
description: The name of the repository
default: ${{ github.event.repository.name }}
required: false
codeql:
description: Filter the languages to only those that are supported by CodeQL
default: 'false'
required: false

outputs:
languages:
Expand Down
23 changes: 21 additions & 2 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,43 @@ interface Input {
token: string;
owner: string;
repo: string;
codeql: boolean;
}

export function getInputs(): Input {
const result = {} as Input;
result.token = core.getInput('github-token');
result.owner = core.getInput('owner');
result.repo = core.getInput('repo');
result.codeql = core.getBooleanInput('codeql');
return result;
}

const codeqlLanguageMapping = {
"csharp": "csharp",
"c#": "csharp",
"cpp": "cpp",
"c": "cpp",
"c++": "cpp",
"go": "go",
"java": "java",
"javascript": "javascript",
"typescript": "javascript",
"python": "python",
"ruby": "ruby"
}

const run = async (): Promise<void> => {
try {
const input = getInputs();
const octokit: ReturnType<typeof github.getOctokit> = github.getOctokit(input.token);
const langResponse = await octokit.request(`GET /repos/${input.owner}/${input.repo}/languages`);
core.debug(JSON.stringify({langResponse}))
const keys = Object.keys(langResponse.data);
core.setOutput('languages', JSON.stringify(keys));
let languages = Object.keys(langResponse.data);
if (input.codeql) {
languages = languages.filter(l => codeqlLanguageMapping[l]);
}
core.setOutput('languages', JSON.stringify(languages));
} catch (error) {
core.startGroup(error instanceof Error ? error.message : JSON.stringify(error));
core.info(JSON.stringify(error, null, 2));
Expand Down

0 comments on commit 3e793a7

Please sign in to comment.