mirror of
https://github.com/actions/labeler.git
synced 2025-12-14 22:25:11 +00:00
Merge branch 'main'
This commit is contained in:
10
src/get-inputs/get-inputs.ts
Normal file
10
src/get-inputs/get-inputs.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as core from '@actions/core';
|
||||
import {getPrNumbers} from './get-pr-numbers';
|
||||
|
||||
export const getInputs = () => ({
|
||||
token: core.getInput('repo-token'),
|
||||
configPath: core.getInput('configuration-path', {required: true}),
|
||||
syncLabels: core.getBooleanInput('sync-labels'),
|
||||
dot: core.getBooleanInput('dot'),
|
||||
prNumbers: getPrNumbers()
|
||||
});
|
||||
28
src/get-inputs/get-pr-numbers.ts
Normal file
28
src/get-inputs/get-pr-numbers.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as github from '@actions/github';
|
||||
|
||||
const getPrNumberFromContext = () =>
|
||||
github.context.payload.pull_request?.number;
|
||||
|
||||
export const getPrNumbers = (): number[] => {
|
||||
const prInput = core.getMultilineInput('pr-number');
|
||||
|
||||
if (!prInput?.length) {
|
||||
return [getPrNumberFromContext()].filter(Boolean) as number[];
|
||||
}
|
||||
|
||||
const result: number[] = [];
|
||||
|
||||
for (const line of prInput) {
|
||||
const prNumber = parseInt(line, 10);
|
||||
|
||||
if (isNaN(prNumber) && prNumber <= 0) {
|
||||
core.warning(`'${prNumber}' is not a valid pull request number`);
|
||||
continue;
|
||||
}
|
||||
|
||||
result.push(prNumber);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
1
src/get-inputs/index.ts
Normal file
1
src/get-inputs/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './get-inputs';
|
||||
Reference in New Issue
Block a user