mirror of
https://github.com/actions/labeler.git
synced 2025-12-13 13:07:24 +00:00
feat(config): support reading from local file if it exists (#394)
* feat(config): support reading from local file if it exists Signed-off-by: Liam Stanley <me@liamstanley.io> * fix: fix review point, update logic * docs: update readme * docs: update readme * feat: add additional logging * chore: update licenses * docs: fix review point in readme.md --------- Signed-off-by: Liam Stanley <me@liamstanley.io> Co-authored-by: IvanZosimov <ivanzosimov@github.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import * as core from '@actions/core';
|
||||
import * as github from '@actions/github';
|
||||
import * as pluginRetry from '@octokit/plugin-retry';
|
||||
import * as yaml from 'js-yaml';
|
||||
import fs from 'fs';
|
||||
import {Minimatch} from 'minimatch';
|
||||
|
||||
interface MatchConfig {
|
||||
@@ -159,7 +160,19 @@ async function getLabelGlobs(
|
||||
): Promise<Map<string, StringOrMatchConfig[]>> {
|
||||
let configurationContent: string;
|
||||
try {
|
||||
configurationContent = await fetchContent(client, configurationPath);
|
||||
if (!fs.existsSync(configurationPath)) {
|
||||
core.info(
|
||||
`The configuration file (path: ${configurationPath}) isn't not found locally, fetching via the api`
|
||||
);
|
||||
configurationContent = await fetchContent(client, configurationPath);
|
||||
} else {
|
||||
core.info(
|
||||
`The configuration file (path: ${configurationPath}) is found locally, reading from the file`
|
||||
);
|
||||
configurationContent = fs.readFileSync(configurationPath, {
|
||||
encoding: 'utf8'
|
||||
});
|
||||
}
|
||||
} catch (e: any) {
|
||||
if (e.name == 'HttpError' || e.name == 'NotFound') {
|
||||
core.warning(
|
||||
|
||||
Reference in New Issue
Block a user