mirror of
https://github.com/actions/add-to-project.git
synced 2025-12-11 04:32:47 +00:00
Merge pull request #598 from actions/dependabot/npm_and_yarn/typescript-5.5.2-fixes
Resolve Regular Expression syntax checking errors
This commit is contained in:
@@ -137,6 +137,7 @@ Using these events ensure that a given issue or pull request, in the workflow's
|
|||||||
## Creating a PAT and adding it to your repository
|
## Creating a PAT and adding it to your repository
|
||||||
|
|
||||||
- Create a new [personal access token](https://github.com/settings/tokens/new). _See [Creating a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) for more information_
|
- Create a new [personal access token](https://github.com/settings/tokens/new). _See [Creating a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) for more information_
|
||||||
|
|
||||||
- For **Tokens (classic)** include the `project` scope; for private repos you will also need `repo` scope.
|
- For **Tokens (classic)** include the `project` scope; for private repos you will also need `repo` scope.
|
||||||
- For **Fine-grained tokens**, you must first select the appropriate _owner_ and associated _repositories_. Then select _Organization permissions -> `projects` `read & write`_, and _Repository permissions -> `issues` `read-only`_ and _`pull requests` `read-only`_.
|
- For **Fine-grained tokens**, you must first select the appropriate _owner_ and associated _repositories_. Then select _Organization permissions -> `projects` `read & write`_, and _Repository permissions -> `issues` `read-only`_ and _`pull requests` `read-only`_.
|
||||||
|
|
||||||
|
|||||||
164
dist/index.js
generated
vendored
164
dist/index.js
generated
vendored
@@ -29,105 +29,96 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.mustGetOwnerTypeQuery = exports.addToProject = void 0;
|
exports.addToProject = addToProject;
|
||||||
|
exports.mustGetOwnerTypeQuery = mustGetOwnerTypeQuery;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const github = __importStar(__nccwpck_require__(5438));
|
const github = __importStar(__nccwpck_require__(5438));
|
||||||
const urlParse = /\/(?<ownerType>orgs|users)\/(?<ownerName>[^/]+)\/projects\/(?<projectNumber>\d+)/;
|
const urlParse = /\/(?<ownerType>orgs|users)\/(?<ownerName>[^/]+)\/projects\/(?<projectNumber>\d+)/;
|
||||||
function addToProject() {
|
async function addToProject() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
||||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
const projectUrl = core.getInput('project-url', { required: true });
|
||||||
const projectUrl = core.getInput('project-url', { required: true });
|
const ghToken = core.getInput('github-token', { required: true });
|
||||||
const ghToken = core.getInput('github-token', { required: true });
|
const labeled = (_a = core
|
||||||
const labeled = (_a = core
|
.getInput('labeled')
|
||||||
.getInput('labeled')
|
.split(',')
|
||||||
.split(',')
|
.map(l => l.trim().toLowerCase())
|
||||||
.map(l => l.trim().toLowerCase())
|
.filter(l => l.length > 0)) !== null && _a !== void 0 ? _a : [];
|
||||||
.filter(l => l.length > 0)) !== null && _a !== void 0 ? _a : [];
|
const labelOperator = core.getInput('label-operator').trim().toLocaleLowerCase();
|
||||||
const labelOperator = core.getInput('label-operator').trim().toLocaleLowerCase();
|
const octokit = github.getOctokit(ghToken);
|
||||||
const octokit = github.getOctokit(ghToken);
|
const issue = (_b = github.context.payload.issue) !== null && _b !== void 0 ? _b : github.context.payload.pull_request;
|
||||||
const issue = (_b = github.context.payload.issue) !== null && _b !== void 0 ? _b : github.context.payload.pull_request;
|
const issueLabels = ((_c = issue === null || issue === void 0 ? void 0 : issue.labels) !== null && _c !== void 0 ? _c : []).map((l) => l.name.toLowerCase());
|
||||||
const issueLabels = ((_c = issue === null || issue === void 0 ? void 0 : issue.labels) !== null && _c !== void 0 ? _c : []).map((l) => l.name.toLowerCase());
|
const issueOwnerName = (_d = github.context.payload.repository) === null || _d === void 0 ? void 0 : _d.owner.login;
|
||||||
const issueOwnerName = (_d = github.context.payload.repository) === null || _d === void 0 ? void 0 : _d.owner.login;
|
core.debug(`Issue/PR owner: ${issueOwnerName}`);
|
||||||
core.debug(`Issue/PR owner: ${issueOwnerName}`);
|
core.debug(`Issue/PR labels: ${issueLabels.join(', ')}`);
|
||||||
core.debug(`Issue/PR labels: ${issueLabels.join(', ')}`);
|
// Ensure the issue matches our `labeled` filter based on the label-operator.
|
||||||
// Ensure the issue matches our `labeled` filter based on the label-operator.
|
if (labelOperator === 'and') {
|
||||||
if (labelOperator === 'and') {
|
if (!labeled.every(l => issueLabels.includes(l))) {
|
||||||
if (!labeled.every(l => issueLabels.includes(l))) {
|
core.info(`Skipping issue ${issue === null || issue === void 0 ? void 0 : issue.number} because it doesn't match all the labels: ${labeled.join(', ')}`);
|
||||||
core.info(`Skipping issue ${issue === null || issue === void 0 ? void 0 : issue.number} because it doesn't match all the labels: ${labeled.join(', ')}`);
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (labelOperator === 'not') {
|
}
|
||||||
if (labeled.length > 0 && issueLabels.some(l => labeled.includes(l))) {
|
else if (labelOperator === 'not') {
|
||||||
core.info(`Skipping issue ${issue === null || issue === void 0 ? void 0 : issue.number} because it contains one of the labels: ${labeled.join(', ')}`);
|
if (labeled.length > 0 && issueLabels.some(l => labeled.includes(l))) {
|
||||||
return;
|
core.info(`Skipping issue ${issue === null || issue === void 0 ? void 0 : issue.number} because it contains one of the labels: ${labeled.join(', ')}`);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
if (labeled.length > 0 && !issueLabels.some(l => labeled.includes(l))) {
|
else {
|
||||||
core.info(`Skipping issue ${issue === null || issue === void 0 ? void 0 : issue.number} because it does not have one of the labels: ${labeled.join(', ')}`);
|
if (labeled.length > 0 && !issueLabels.some(l => labeled.includes(l))) {
|
||||||
return;
|
core.info(`Skipping issue ${issue === null || issue === void 0 ? void 0 : issue.number} because it does not have one of the labels: ${labeled.join(', ')}`);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
core.debug(`Project URL: ${projectUrl}`);
|
}
|
||||||
const urlMatch = projectUrl.match(urlParse);
|
core.debug(`Project URL: ${projectUrl}`);
|
||||||
if (!urlMatch) {
|
const urlMatch = projectUrl.match(urlParse);
|
||||||
throw new Error(`Invalid project URL: ${projectUrl}. Project URL should match the format <GitHub server domain name>/<orgs-or-users>/<ownerName>/projects/<projectNumber>`);
|
if (!urlMatch) {
|
||||||
}
|
throw new Error(`Invalid project URL: ${projectUrl}. Project URL should match the format <GitHub server domain name>/<orgs-or-users>/<ownerName>/projects/<projectNumber>`);
|
||||||
const projectOwnerName = (_e = urlMatch.groups) === null || _e === void 0 ? void 0 : _e.ownerName;
|
}
|
||||||
const projectNumber = parseInt((_g = (_f = urlMatch.groups) === null || _f === void 0 ? void 0 : _f.projectNumber) !== null && _g !== void 0 ? _g : '', 10);
|
const projectOwnerName = (_e = urlMatch.groups) === null || _e === void 0 ? void 0 : _e.ownerName;
|
||||||
const ownerType = (_h = urlMatch.groups) === null || _h === void 0 ? void 0 : _h.ownerType;
|
const projectNumber = parseInt((_g = (_f = urlMatch.groups) === null || _f === void 0 ? void 0 : _f.projectNumber) !== null && _g !== void 0 ? _g : '', 10);
|
||||||
const ownerTypeQuery = mustGetOwnerTypeQuery(ownerType);
|
const ownerType = (_h = urlMatch.groups) === null || _h === void 0 ? void 0 : _h.ownerType;
|
||||||
core.debug(`Project owner: ${projectOwnerName}`);
|
const ownerTypeQuery = mustGetOwnerTypeQuery(ownerType);
|
||||||
core.debug(`Project number: ${projectNumber}`);
|
core.debug(`Project owner: ${projectOwnerName}`);
|
||||||
core.debug(`Project owner type: ${ownerType}`);
|
core.debug(`Project number: ${projectNumber}`);
|
||||||
// First, use the GraphQL API to request the project's node ID.
|
core.debug(`Project owner type: ${ownerType}`);
|
||||||
const idResp = yield octokit.graphql(`query getProject($projectOwnerName: String!, $projectNumber: Int!) {
|
// First, use the GraphQL API to request the project's node ID.
|
||||||
|
const idResp = await octokit.graphql(`query getProject($projectOwnerName: String!, $projectNumber: Int!) {
|
||||||
${ownerTypeQuery}(login: $projectOwnerName) {
|
${ownerTypeQuery}(login: $projectOwnerName) {
|
||||||
projectV2(number: $projectNumber) {
|
projectV2(number: $projectNumber) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`, {
|
}`, {
|
||||||
projectOwnerName,
|
projectOwnerName,
|
||||||
projectNumber,
|
projectNumber,
|
||||||
});
|
});
|
||||||
const projectId = (_j = idResp[ownerTypeQuery]) === null || _j === void 0 ? void 0 : _j.projectV2.id;
|
const projectId = (_j = idResp[ownerTypeQuery]) === null || _j === void 0 ? void 0 : _j.projectV2.id;
|
||||||
const contentId = issue === null || issue === void 0 ? void 0 : issue.node_id;
|
const contentId = issue === null || issue === void 0 ? void 0 : issue.node_id;
|
||||||
core.debug(`Project node ID: ${projectId}`);
|
core.debug(`Project node ID: ${projectId}`);
|
||||||
core.debug(`Content ID: ${contentId}`);
|
core.debug(`Content ID: ${contentId}`);
|
||||||
// Next, use the GraphQL API to add the issue to the project.
|
// Next, use the GraphQL API to add the issue to the project.
|
||||||
// If the issue has the same owner as the project, we can directly
|
// If the issue has the same owner as the project, we can directly
|
||||||
// add a project item. Otherwise, we add a draft issue.
|
// add a project item. Otherwise, we add a draft issue.
|
||||||
if (issueOwnerName === projectOwnerName) {
|
if (issueOwnerName === projectOwnerName) {
|
||||||
core.info('Creating project item');
|
core.info('Creating project item');
|
||||||
const addResp = yield octokit.graphql(`mutation addIssueToProject($input: AddProjectV2ItemByIdInput!) {
|
const addResp = await octokit.graphql(`mutation addIssueToProject($input: AddProjectV2ItemByIdInput!) {
|
||||||
addProjectV2ItemById(input: $input) {
|
addProjectV2ItemById(input: $input) {
|
||||||
item {
|
item {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`, {
|
}`, {
|
||||||
input: {
|
input: {
|
||||||
projectId,
|
projectId,
|
||||||
contentId,
|
contentId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
core.setOutput('itemId', addResp.addProjectV2ItemById.item.id);
|
core.setOutput('itemId', addResp.addProjectV2ItemById.item.id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info('Creating draft issue in project');
|
core.info('Creating draft issue in project');
|
||||||
const addResp = yield octokit.graphql(`mutation addDraftIssueToProject($projectId: ID!, $title: String!) {
|
const addResp = await octokit.graphql(`mutation addDraftIssueToProject($projectId: ID!, $title: String!) {
|
||||||
addProjectV2DraftIssue(input: {
|
addProjectV2DraftIssue(input: {
|
||||||
projectId: $projectId,
|
projectId: $projectId,
|
||||||
title: $title
|
title: $title
|
||||||
@@ -137,14 +128,12 @@ function addToProject() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`, {
|
}`, {
|
||||||
projectId,
|
projectId,
|
||||||
title: issue === null || issue === void 0 ? void 0 : issue.html_url,
|
title: issue === null || issue === void 0 ? void 0 : issue.html_url,
|
||||||
});
|
});
|
||||||
core.setOutput('itemId', addResp.addProjectV2DraftIssue.projectItem.id);
|
core.setOutput('itemId', addResp.addProjectV2DraftIssue.projectItem.id);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
exports.addToProject = addToProject;
|
|
||||||
function mustGetOwnerTypeQuery(ownerType) {
|
function mustGetOwnerTypeQuery(ownerType) {
|
||||||
const ownerTypeQuery = ownerType === 'orgs' ? 'organization' : ownerType === 'users' ? 'user' : null;
|
const ownerTypeQuery = ownerType === 'orgs' ? 'organization' : ownerType === 'users' ? 'user' : null;
|
||||||
if (!ownerTypeQuery) {
|
if (!ownerTypeQuery) {
|
||||||
@@ -152,7 +141,6 @@ function mustGetOwnerTypeQuery(ownerType) {
|
|||||||
}
|
}
|
||||||
return ownerTypeQuery;
|
return ownerTypeQuery;
|
||||||
}
|
}
|
||||||
exports.mustGetOwnerTypeQuery = mustGetOwnerTypeQuery;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|||||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2015" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
|
"target": "ES2018" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
|
||||||
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
||||||
"outDir": "./lib" /* Redirect output structure to the directory. */,
|
"outDir": "./lib" /* Redirect output structure to the directory. */,
|
||||||
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
|
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
|
||||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
||||||
"noUncheckedIndexedAccess": true,
|
"noUncheckedIndexedAccess": true,
|
||||||
"lib": ["ES2015"]
|
"lib": ["ES2018"]
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "**/*.test.ts"]
|
"exclude": ["node_modules", "**/*.test.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user