mirror of
https://github.com/actions/labeler.git
synced 2026-01-02 17:47:18 +08:00
build
This commit is contained in:
26
src/main.ts
26
src/main.ts
@@ -1,17 +1,17 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as github from '@actions/github';
|
||||
import * as yaml from 'js-yaml';
|
||||
import {Minimatch} from 'minimatch';
|
||||
import * as core from "@actions/core";
|
||||
import * as github from "@actions/github";
|
||||
import * as yaml from "js-yaml";
|
||||
import { Minimatch } from "minimatch";
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const token = core.getInput('repo-token', {required: true});
|
||||
const configPath = core.getInput('configuration-path', {required: true});
|
||||
const token = core.getInput("repo-token", { required: true });
|
||||
const configPath = core.getInput("configuration-path", { required: true });
|
||||
const syncLabels = !!core.getInput("sync-labels", { required: false });
|
||||
|
||||
const prNumber = getPrNumber();
|
||||
if (!prNumber) {
|
||||
console.log('Could not get pull request number from context, exiting');
|
||||
console.log("Could not get pull request number from context, exiting");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ async function getChangedFiles(
|
||||
client: github.GitHub,
|
||||
prNumber: number
|
||||
): Promise<string[]> {
|
||||
const listFilesOptions = client.pulls.listFiles.endpoint.merge({
|
||||
const listFilesOptions = client.pulls.listFiles.endpoint.merge({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
pull_number: prNumber
|
||||
@@ -69,9 +69,9 @@ async function getChangedFiles(
|
||||
const listFilesResponse = await client.paginate(listFilesOptions);
|
||||
const changedFiles = listFilesResponse.map(f => f.filename);
|
||||
|
||||
core.debug('found changed files:');
|
||||
core.debug("found changed files:");
|
||||
for (const file of changedFiles) {
|
||||
core.debug(' ' + file);
|
||||
core.debug(" " + file);
|
||||
}
|
||||
|
||||
return changedFiles;
|
||||
@@ -104,20 +104,20 @@ async function fetchContent(
|
||||
ref: github.context.sha
|
||||
});
|
||||
|
||||
if (!('content' in response.data)) {
|
||||
if (!("content" in response.data)) {
|
||||
throw new Error(`The path '${repoPath}' is not a file`);
|
||||
}
|
||||
if (!response.data.content) {
|
||||
throw new Error(`The file '${repoPath}' has no content`);
|
||||
}
|
||||
|
||||
return Buffer.from(response.data.content, 'base64').toString();
|
||||
return Buffer.from(response.data.content, "base64").toString();
|
||||
}
|
||||
|
||||
function getLabelGlobMapFromObject(configObject: any): Map<string, string[]> {
|
||||
const labelGlobs: Map<string, string[]> = new Map();
|
||||
for (const label in configObject) {
|
||||
if (typeof configObject[label] === 'string') {
|
||||
if (typeof configObject[label] === "string") {
|
||||
labelGlobs.set(label, [configObject[label]]);
|
||||
} else if (configObject[label] instanceof Array) {
|
||||
labelGlobs.set(label, configObject[label]);
|
||||
|
||||
Reference in New Issue
Block a user