mirror of
https://github.com/actions/add-to-project.git
synced 2025-12-11 04:32:47 +00:00
Build and package
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
|
||||
|
||||
- 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 **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`_.
|
||||
|
||||
|
||||
24
dist/index.js
generated
vendored
24
dist/index.js
generated
vendored
@@ -29,22 +29,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
__setModuleDefault(result, mod);
|
||||
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 }));
|
||||
exports.mustGetOwnerTypeQuery = exports.addToProject = void 0;
|
||||
exports.addToProject = addToProject;
|
||||
exports.mustGetOwnerTypeQuery = mustGetOwnerTypeQuery;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const github = __importStar(__nccwpck_require__(5438));
|
||||
const urlParse = /\/(?<ownerType>orgs|users)\/(?<ownerName>[^/]+)\/projects\/(?<projectNumber>\d+)/;
|
||||
function addToProject() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
async function addToProject() {
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
||||
const projectUrl = core.getInput('project-url', { required: true });
|
||||
const ghToken = core.getInput('github-token', { required: true });
|
||||
@@ -92,7 +83,7 @@ function addToProject() {
|
||||
core.debug(`Project number: ${projectNumber}`);
|
||||
core.debug(`Project owner type: ${ownerType}`);
|
||||
// First, use the GraphQL API to request the project's node ID.
|
||||
const idResp = yield octokit.graphql(`query getProject($projectOwnerName: String!, $projectNumber: Int!) {
|
||||
const idResp = await octokit.graphql(`query getProject($projectOwnerName: String!, $projectNumber: Int!) {
|
||||
${ownerTypeQuery}(login: $projectOwnerName) {
|
||||
projectV2(number: $projectNumber) {
|
||||
id
|
||||
@@ -111,7 +102,7 @@ function addToProject() {
|
||||
// add a project item. Otherwise, we add a draft issue.
|
||||
if (issueOwnerName === projectOwnerName) {
|
||||
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) {
|
||||
item {
|
||||
id
|
||||
@@ -127,7 +118,7 @@ function addToProject() {
|
||||
}
|
||||
else {
|
||||
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: {
|
||||
projectId: $projectId,
|
||||
title: $title
|
||||
@@ -142,9 +133,7 @@ function addToProject() {
|
||||
});
|
||||
core.setOutput('itemId', addResp.addProjectV2DraftIssue.projectItem.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.addToProject = addToProject;
|
||||
function mustGetOwnerTypeQuery(ownerType) {
|
||||
const ownerTypeQuery = ownerType === 'orgs' ? 'organization' : ownerType === 'users' ? 'user' : null;
|
||||
if (!ownerTypeQuery) {
|
||||
@@ -152,7 +141,6 @@ function mustGetOwnerTypeQuery(ownerType) {
|
||||
}
|
||||
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": {
|
||||
"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'. */,
|
||||
"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. */,
|
||||
@@ -8,7 +8,7 @@
|
||||
"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'. */,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"lib": ["ES2015"]
|
||||
"lib": ["ES2018"]
|
||||
},
|
||||
"exclude": ["node_modules", "**/*.test.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user