@backstage/plugin-scaffolder-backend-module-github 0.0.0-nightly-20231213021616
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +5 -0
- package/dist/index.cjs.js +2426 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +327 -0
- package/package.json +49 -0
|
@@ -0,0 +1,2426 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var errors = require('@backstage/errors');
|
|
6
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
7
|
+
var octokit = require('octokit');
|
|
8
|
+
var integration = require('@backstage/integration');
|
|
9
|
+
var Sodium = require('libsodium-wrappers');
|
|
10
|
+
var yaml = require('yaml');
|
|
11
|
+
var webhooks = require('@octokit/webhooks');
|
|
12
|
+
var path = require('path');
|
|
13
|
+
var backendCommon = require('@backstage/backend-common');
|
|
14
|
+
var octokitPluginCreatePullRequest = require('octokit-plugin-create-pull-request');
|
|
15
|
+
|
|
16
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
|
+
|
|
18
|
+
var Sodium__default = /*#__PURE__*/_interopDefaultLegacy(Sodium);
|
|
19
|
+
var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
|
|
20
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
21
|
+
|
|
22
|
+
const enableBranchProtectionOnDefaultRepoBranch = async ({
|
|
23
|
+
repoName,
|
|
24
|
+
client,
|
|
25
|
+
owner,
|
|
26
|
+
logger,
|
|
27
|
+
requireCodeOwnerReviews,
|
|
28
|
+
bypassPullRequestAllowances,
|
|
29
|
+
requiredApprovingReviewCount,
|
|
30
|
+
restrictions,
|
|
31
|
+
requiredStatusCheckContexts = [],
|
|
32
|
+
requireBranchesToBeUpToDate = true,
|
|
33
|
+
requiredConversationResolution = false,
|
|
34
|
+
defaultBranch = "master",
|
|
35
|
+
enforceAdmins = true,
|
|
36
|
+
dismissStaleReviews = false,
|
|
37
|
+
requiredCommitSigning = false
|
|
38
|
+
}) => {
|
|
39
|
+
const tryOnce = async () => {
|
|
40
|
+
try {
|
|
41
|
+
await client.rest.repos.updateBranchProtection({
|
|
42
|
+
mediaType: {
|
|
43
|
+
/**
|
|
44
|
+
* 👇 we need this preview because allowing a custom
|
|
45
|
+
* reviewer count on branch protection is a preview
|
|
46
|
+
* feature
|
|
47
|
+
*
|
|
48
|
+
* More here: https://docs.github.com/en/rest/overview/api-previews#require-multiple-approving-reviews
|
|
49
|
+
*/
|
|
50
|
+
previews: ["luke-cage-preview"]
|
|
51
|
+
},
|
|
52
|
+
owner,
|
|
53
|
+
repo: repoName,
|
|
54
|
+
branch: defaultBranch,
|
|
55
|
+
required_status_checks: {
|
|
56
|
+
strict: requireBranchesToBeUpToDate,
|
|
57
|
+
contexts: requiredStatusCheckContexts
|
|
58
|
+
},
|
|
59
|
+
restrictions: restrictions != null ? restrictions : null,
|
|
60
|
+
enforce_admins: enforceAdmins,
|
|
61
|
+
required_pull_request_reviews: {
|
|
62
|
+
required_approving_review_count: requiredApprovingReviewCount,
|
|
63
|
+
require_code_owner_reviews: requireCodeOwnerReviews,
|
|
64
|
+
bypass_pull_request_allowances: bypassPullRequestAllowances,
|
|
65
|
+
dismiss_stale_reviews: dismissStaleReviews
|
|
66
|
+
},
|
|
67
|
+
required_conversation_resolution: requiredConversationResolution
|
|
68
|
+
});
|
|
69
|
+
if (requiredCommitSigning) {
|
|
70
|
+
await client.rest.repos.createCommitSignatureProtection({
|
|
71
|
+
owner,
|
|
72
|
+
repo: repoName,
|
|
73
|
+
branch: defaultBranch
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
} catch (e) {
|
|
77
|
+
errors.assertError(e);
|
|
78
|
+
if (e.message.includes(
|
|
79
|
+
"Upgrade to GitHub Pro or make this repository public to enable this feature"
|
|
80
|
+
)) {
|
|
81
|
+
logger.warn(
|
|
82
|
+
"Branch protection was not enabled as it requires GitHub Pro for private repositories"
|
|
83
|
+
);
|
|
84
|
+
} else {
|
|
85
|
+
throw e;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
try {
|
|
90
|
+
await tryOnce();
|
|
91
|
+
} catch (e) {
|
|
92
|
+
if (!e.message.includes("Branch not found")) {
|
|
93
|
+
throw e;
|
|
94
|
+
}
|
|
95
|
+
await new Promise((resolve) => setTimeout(resolve, 600));
|
|
96
|
+
await tryOnce();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
function entityRefToName(name) {
|
|
100
|
+
return name.replace(/^.*[:/]/g, "");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const DEFAULT_TIMEOUT_MS = 6e4;
|
|
104
|
+
async function getOctokitOptions(options) {
|
|
105
|
+
var _a;
|
|
106
|
+
const { integrations, credentialsProvider, repoUrl, token } = options;
|
|
107
|
+
const { owner, repo, host } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
108
|
+
const requestOptions = {
|
|
109
|
+
// set timeout to 60 seconds
|
|
110
|
+
timeout: DEFAULT_TIMEOUT_MS
|
|
111
|
+
};
|
|
112
|
+
if (!owner) {
|
|
113
|
+
throw new errors.InputError(`No owner provided for repo ${repoUrl}`);
|
|
114
|
+
}
|
|
115
|
+
const integrationConfig = (_a = integrations.github.byHost(host)) == null ? void 0 : _a.config;
|
|
116
|
+
if (!integrationConfig) {
|
|
117
|
+
throw new errors.InputError(`No integration for host ${host}`);
|
|
118
|
+
}
|
|
119
|
+
if (token) {
|
|
120
|
+
return {
|
|
121
|
+
auth: token,
|
|
122
|
+
baseUrl: integrationConfig.apiBaseUrl,
|
|
123
|
+
previews: ["nebula-preview"],
|
|
124
|
+
request: requestOptions
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const githubCredentialsProvider = credentialsProvider != null ? credentialsProvider : integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations);
|
|
128
|
+
const { token: credentialProviderToken } = await githubCredentialsProvider.getCredentials({
|
|
129
|
+
url: `https://${host}/${encodeURIComponent(owner)}/${encodeURIComponent(
|
|
130
|
+
repo
|
|
131
|
+
)}`
|
|
132
|
+
});
|
|
133
|
+
if (!credentialProviderToken) {
|
|
134
|
+
throw new errors.InputError(
|
|
135
|
+
`No token available for host: ${host}, with owner ${owner}, and repo ${repo}`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
auth: credentialProviderToken,
|
|
140
|
+
baseUrl: integrationConfig.apiBaseUrl,
|
|
141
|
+
previews: ["nebula-preview"]
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, repoVisibility, description, homepage, deleteBranchOnMerge, allowMergeCommit, allowSquashMerge, squashMergeCommitTitle, squashMergeCommitMessage, allowRebaseMerge, allowAutoMerge, access, collaborators, hasProjects, hasWiki, hasIssues, topics, repoVariables, secrets, logger) {
|
|
145
|
+
const user = await client.rest.users.getByUsername({
|
|
146
|
+
username: owner
|
|
147
|
+
});
|
|
148
|
+
if (access == null ? void 0 : access.startsWith(`${owner}/`)) {
|
|
149
|
+
await validateAccessTeam(client, access);
|
|
150
|
+
}
|
|
151
|
+
const repoCreationPromise = user.data.type === "Organization" ? client.rest.repos.createInOrg({
|
|
152
|
+
name: repo,
|
|
153
|
+
org: owner,
|
|
154
|
+
private: repoVisibility === "private",
|
|
155
|
+
// @ts-ignore https://github.com/octokit/types.ts/issues/522
|
|
156
|
+
visibility: repoVisibility,
|
|
157
|
+
description,
|
|
158
|
+
delete_branch_on_merge: deleteBranchOnMerge,
|
|
159
|
+
allow_merge_commit: allowMergeCommit,
|
|
160
|
+
allow_squash_merge: allowSquashMerge,
|
|
161
|
+
squash_merge_commit_title: squashMergeCommitTitle,
|
|
162
|
+
squash_merge_commit_message: squashMergeCommitMessage,
|
|
163
|
+
allow_rebase_merge: allowRebaseMerge,
|
|
164
|
+
allow_auto_merge: allowAutoMerge,
|
|
165
|
+
homepage,
|
|
166
|
+
has_projects: hasProjects,
|
|
167
|
+
has_wiki: hasWiki,
|
|
168
|
+
has_issues: hasIssues
|
|
169
|
+
}) : client.rest.repos.createForAuthenticatedUser({
|
|
170
|
+
name: repo,
|
|
171
|
+
private: repoVisibility === "private",
|
|
172
|
+
description,
|
|
173
|
+
delete_branch_on_merge: deleteBranchOnMerge,
|
|
174
|
+
allow_merge_commit: allowMergeCommit,
|
|
175
|
+
allow_squash_merge: allowSquashMerge,
|
|
176
|
+
squash_merge_commit_title: squashMergeCommitTitle,
|
|
177
|
+
squash_merge_commit_message: squashMergeCommitMessage,
|
|
178
|
+
allow_rebase_merge: allowRebaseMerge,
|
|
179
|
+
allow_auto_merge: allowAutoMerge,
|
|
180
|
+
homepage,
|
|
181
|
+
has_projects: hasProjects,
|
|
182
|
+
has_wiki: hasWiki,
|
|
183
|
+
has_issues: hasIssues
|
|
184
|
+
});
|
|
185
|
+
let newRepo;
|
|
186
|
+
try {
|
|
187
|
+
newRepo = (await repoCreationPromise).data;
|
|
188
|
+
} catch (e) {
|
|
189
|
+
errors.assertError(e);
|
|
190
|
+
if (e.message === "Resource not accessible by integration") {
|
|
191
|
+
logger.warn(
|
|
192
|
+
`The GitHub app or token provided may not have the required permissions to create the ${user.data.type} repository ${owner}/${repo}.`
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
throw new Error(
|
|
196
|
+
`Failed to create the ${user.data.type} repository ${owner}/${repo}, ${e.message}`
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
if (access == null ? void 0 : access.startsWith(`${owner}/`)) {
|
|
200
|
+
const [, team] = access.split("/");
|
|
201
|
+
await client.rest.teams.addOrUpdateRepoPermissionsInOrg({
|
|
202
|
+
org: owner,
|
|
203
|
+
team_slug: team,
|
|
204
|
+
owner,
|
|
205
|
+
repo,
|
|
206
|
+
permission: "admin"
|
|
207
|
+
});
|
|
208
|
+
} else if (access && access !== owner) {
|
|
209
|
+
await client.rest.repos.addCollaborator({
|
|
210
|
+
owner,
|
|
211
|
+
repo,
|
|
212
|
+
username: access,
|
|
213
|
+
permission: "admin"
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
if (collaborators) {
|
|
217
|
+
for (const collaborator of collaborators) {
|
|
218
|
+
try {
|
|
219
|
+
if ("user" in collaborator) {
|
|
220
|
+
await client.rest.repos.addCollaborator({
|
|
221
|
+
owner,
|
|
222
|
+
repo,
|
|
223
|
+
username: entityRefToName(collaborator.user),
|
|
224
|
+
permission: collaborator.access
|
|
225
|
+
});
|
|
226
|
+
} else if ("team" in collaborator) {
|
|
227
|
+
await client.rest.teams.addOrUpdateRepoPermissionsInOrg({
|
|
228
|
+
org: owner,
|
|
229
|
+
team_slug: entityRefToName(collaborator.team),
|
|
230
|
+
owner,
|
|
231
|
+
repo,
|
|
232
|
+
permission: collaborator.access
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
} catch (e) {
|
|
236
|
+
errors.assertError(e);
|
|
237
|
+
const name = extractCollaboratorName(collaborator);
|
|
238
|
+
logger.warn(
|
|
239
|
+
`Skipping ${collaborator.access} access for ${name}, ${e.message}`
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (topics) {
|
|
245
|
+
try {
|
|
246
|
+
await client.rest.repos.replaceAllTopics({
|
|
247
|
+
owner,
|
|
248
|
+
repo,
|
|
249
|
+
names: topics.map((t) => t.toLowerCase())
|
|
250
|
+
});
|
|
251
|
+
} catch (e) {
|
|
252
|
+
errors.assertError(e);
|
|
253
|
+
logger.warn(`Skipping topics ${topics.join(" ")}, ${e.message}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
for (const [key, value] of Object.entries(repoVariables != null ? repoVariables : {})) {
|
|
257
|
+
await client.rest.actions.createRepoVariable({
|
|
258
|
+
owner,
|
|
259
|
+
repo,
|
|
260
|
+
name: key,
|
|
261
|
+
value
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
if (secrets) {
|
|
265
|
+
const publicKeyResponse = await client.rest.actions.getRepoPublicKey({
|
|
266
|
+
owner,
|
|
267
|
+
repo
|
|
268
|
+
});
|
|
269
|
+
await Sodium__default["default"].ready;
|
|
270
|
+
const binaryKey = Sodium__default["default"].from_base64(
|
|
271
|
+
publicKeyResponse.data.key,
|
|
272
|
+
Sodium__default["default"].base64_variants.ORIGINAL
|
|
273
|
+
);
|
|
274
|
+
for (const [key, value] of Object.entries(secrets)) {
|
|
275
|
+
const binarySecret = Sodium__default["default"].from_string(value);
|
|
276
|
+
const encryptedBinarySecret = Sodium__default["default"].crypto_box_seal(
|
|
277
|
+
binarySecret,
|
|
278
|
+
binaryKey
|
|
279
|
+
);
|
|
280
|
+
const encryptedBase64Secret = Sodium__default["default"].to_base64(
|
|
281
|
+
encryptedBinarySecret,
|
|
282
|
+
Sodium__default["default"].base64_variants.ORIGINAL
|
|
283
|
+
);
|
|
284
|
+
await client.rest.actions.createOrUpdateRepoSecret({
|
|
285
|
+
owner,
|
|
286
|
+
repo,
|
|
287
|
+
secret_name: key,
|
|
288
|
+
encrypted_value: encryptedBase64Secret,
|
|
289
|
+
key_id: publicKeyResponse.data.key_id
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return newRepo;
|
|
294
|
+
}
|
|
295
|
+
async function initRepoPushAndProtect(remoteUrl, password, workspacePath, sourcePath, defaultBranch, protectDefaultBranch, protectEnforceAdmins, owner, client, repo, requireCodeOwnerReviews, bypassPullRequestAllowances, requiredApprovingReviewCount, restrictions, requiredStatusCheckContexts, requireBranchesToBeUpToDate, requiredConversationResolution, config, logger, gitCommitMessage, gitAuthorName, gitAuthorEmail, dismissStaleReviews, requiredCommitSigning) {
|
|
296
|
+
const gitAuthorInfo = {
|
|
297
|
+
name: gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name"),
|
|
298
|
+
email: gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email")
|
|
299
|
+
};
|
|
300
|
+
const commitMessage = gitCommitMessage ? gitCommitMessage : config.getOptionalString("scaffolder.defaultCommitMessage");
|
|
301
|
+
const commitResult = await pluginScaffolderNode.initRepoAndPush({
|
|
302
|
+
dir: pluginScaffolderNode.getRepoSourceDirectory(workspacePath, sourcePath),
|
|
303
|
+
remoteUrl,
|
|
304
|
+
defaultBranch,
|
|
305
|
+
auth: {
|
|
306
|
+
username: "x-access-token",
|
|
307
|
+
password
|
|
308
|
+
},
|
|
309
|
+
logger,
|
|
310
|
+
commitMessage,
|
|
311
|
+
gitAuthorInfo
|
|
312
|
+
});
|
|
313
|
+
if (protectDefaultBranch) {
|
|
314
|
+
try {
|
|
315
|
+
await enableBranchProtectionOnDefaultRepoBranch({
|
|
316
|
+
owner,
|
|
317
|
+
client,
|
|
318
|
+
repoName: repo,
|
|
319
|
+
logger,
|
|
320
|
+
defaultBranch,
|
|
321
|
+
bypassPullRequestAllowances,
|
|
322
|
+
requiredApprovingReviewCount,
|
|
323
|
+
restrictions,
|
|
324
|
+
requireCodeOwnerReviews,
|
|
325
|
+
requiredStatusCheckContexts,
|
|
326
|
+
requireBranchesToBeUpToDate,
|
|
327
|
+
requiredConversationResolution,
|
|
328
|
+
enforceAdmins: protectEnforceAdmins,
|
|
329
|
+
dismissStaleReviews,
|
|
330
|
+
requiredCommitSigning
|
|
331
|
+
});
|
|
332
|
+
} catch (e) {
|
|
333
|
+
errors.assertError(e);
|
|
334
|
+
logger.warn(
|
|
335
|
+
`Skipping: default branch protection on '${repo}', ${e.message}`
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return { commitHash: commitResult.commitHash };
|
|
340
|
+
}
|
|
341
|
+
function extractCollaboratorName(collaborator) {
|
|
342
|
+
if ("username" in collaborator)
|
|
343
|
+
return collaborator.username;
|
|
344
|
+
if ("user" in collaborator)
|
|
345
|
+
return collaborator.user;
|
|
346
|
+
return collaborator.team;
|
|
347
|
+
}
|
|
348
|
+
async function validateAccessTeam(client, access) {
|
|
349
|
+
const [org, team_slug] = access.split("/");
|
|
350
|
+
try {
|
|
351
|
+
await client.rest.teams.getByName({
|
|
352
|
+
org,
|
|
353
|
+
team_slug
|
|
354
|
+
});
|
|
355
|
+
} catch (e) {
|
|
356
|
+
if (e.response.data.message === "Not Found") {
|
|
357
|
+
const message = `Received 'Not Found' from the API; one of org:
|
|
358
|
+
${org} or team: ${team_slug} was not found within GitHub.`;
|
|
359
|
+
throw new errors.NotFoundError(message);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const examples$8 = [
|
|
365
|
+
{
|
|
366
|
+
description: "GitHub Action Workflow Without Inputs.",
|
|
367
|
+
example: yaml__default["default"].stringify({
|
|
368
|
+
steps: [
|
|
369
|
+
{
|
|
370
|
+
action: "github:actions:dispatch",
|
|
371
|
+
name: "Dispatch Github Action Workflow",
|
|
372
|
+
input: {
|
|
373
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
374
|
+
workflowId: "WORKFLOW_ID",
|
|
375
|
+
branchOrTagName: "main"
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
]
|
|
379
|
+
})
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
description: "GitHub Action Workflow With Inputs",
|
|
383
|
+
example: yaml__default["default"].stringify({
|
|
384
|
+
steps: [
|
|
385
|
+
{
|
|
386
|
+
action: "github:actions:dispatch",
|
|
387
|
+
name: "Dispatch Github Action Workflow with inputs",
|
|
388
|
+
input: {
|
|
389
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
390
|
+
workflowId: "WORKFLOW_ID",
|
|
391
|
+
branchOrTagName: "main",
|
|
392
|
+
workflowInputs: {
|
|
393
|
+
input1: "value1",
|
|
394
|
+
input2: "value2"
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
]
|
|
399
|
+
})
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
description: "GitHub Action Workflow With Custom Token",
|
|
403
|
+
example: yaml__default["default"].stringify({
|
|
404
|
+
steps: [
|
|
405
|
+
{
|
|
406
|
+
action: "github:actions:dispatch",
|
|
407
|
+
name: "Dispatch GitHub Action Workflow (custom token)",
|
|
408
|
+
input: {
|
|
409
|
+
repoUrl: "github.com?repo=reponame&owner=owner",
|
|
410
|
+
workflowId: "WORKFLOW_ID",
|
|
411
|
+
branchOrTagName: "release-1.0",
|
|
412
|
+
token: "${{ secrets.MY_CUSTOM_TOKEN }}"
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
]
|
|
416
|
+
})
|
|
417
|
+
}
|
|
418
|
+
];
|
|
419
|
+
|
|
420
|
+
function createGithubActionsDispatchAction(options) {
|
|
421
|
+
const { integrations, githubCredentialsProvider } = options;
|
|
422
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
423
|
+
id: "github:actions:dispatch",
|
|
424
|
+
description: "Dispatches a GitHub Action workflow for a given branch or tag",
|
|
425
|
+
examples: examples$8,
|
|
426
|
+
schema: {
|
|
427
|
+
input: {
|
|
428
|
+
type: "object",
|
|
429
|
+
required: ["repoUrl", "workflowId", "branchOrTagName"],
|
|
430
|
+
properties: {
|
|
431
|
+
repoUrl: {
|
|
432
|
+
title: "Repository Location",
|
|
433
|
+
description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,
|
|
434
|
+
type: "string"
|
|
435
|
+
},
|
|
436
|
+
workflowId: {
|
|
437
|
+
title: "Workflow ID",
|
|
438
|
+
description: "The GitHub Action Workflow filename",
|
|
439
|
+
type: "string"
|
|
440
|
+
},
|
|
441
|
+
branchOrTagName: {
|
|
442
|
+
title: "Branch or Tag name",
|
|
443
|
+
description: "The git branch or tag name used to dispatch the workflow",
|
|
444
|
+
type: "string"
|
|
445
|
+
},
|
|
446
|
+
workflowInputs: {
|
|
447
|
+
title: "Workflow Inputs",
|
|
448
|
+
description: "Inputs keys and values to send to GitHub Action configured on the workflow file. The maximum number of properties is 10. ",
|
|
449
|
+
type: "object"
|
|
450
|
+
},
|
|
451
|
+
token: {
|
|
452
|
+
title: "Authentication Token",
|
|
453
|
+
type: "string",
|
|
454
|
+
description: "The GITHUB_TOKEN to use for authorization to GitHub"
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
async handler(ctx) {
|
|
460
|
+
const {
|
|
461
|
+
repoUrl,
|
|
462
|
+
workflowId,
|
|
463
|
+
branchOrTagName,
|
|
464
|
+
workflowInputs,
|
|
465
|
+
token: providedToken
|
|
466
|
+
} = ctx.input;
|
|
467
|
+
ctx.logger.info(
|
|
468
|
+
`Dispatching workflow ${workflowId} for repo ${repoUrl} on ${branchOrTagName}`
|
|
469
|
+
);
|
|
470
|
+
const { owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
471
|
+
if (!owner) {
|
|
472
|
+
throw new errors.InputError("Invalid repository owner provided in repoUrl");
|
|
473
|
+
}
|
|
474
|
+
const client = new octokit.Octokit(
|
|
475
|
+
await getOctokitOptions({
|
|
476
|
+
integrations,
|
|
477
|
+
repoUrl,
|
|
478
|
+
credentialsProvider: githubCredentialsProvider,
|
|
479
|
+
token: providedToken
|
|
480
|
+
})
|
|
481
|
+
);
|
|
482
|
+
await client.rest.actions.createWorkflowDispatch({
|
|
483
|
+
owner,
|
|
484
|
+
repo,
|
|
485
|
+
workflow_id: workflowId,
|
|
486
|
+
ref: branchOrTagName,
|
|
487
|
+
inputs: workflowInputs
|
|
488
|
+
});
|
|
489
|
+
ctx.logger.info(`Workflow ${workflowId} dispatched successfully`);
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const examples$7 = [
|
|
495
|
+
{
|
|
496
|
+
description: "Add labels to pull request or issue",
|
|
497
|
+
example: yaml__default["default"].stringify({
|
|
498
|
+
steps: [
|
|
499
|
+
{
|
|
500
|
+
action: "github:issues:label",
|
|
501
|
+
name: "Add labels to pull request or issue",
|
|
502
|
+
input: {
|
|
503
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
504
|
+
number: "1",
|
|
505
|
+
labels: ["bug"]
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
]
|
|
509
|
+
})
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
description: "Add labels to pull request or issue with specific token",
|
|
513
|
+
example: yaml__default["default"].stringify({
|
|
514
|
+
steps: [
|
|
515
|
+
{
|
|
516
|
+
action: "github:issues:label",
|
|
517
|
+
name: "Add labels to pull request or issue with token",
|
|
518
|
+
input: {
|
|
519
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
520
|
+
number: "1",
|
|
521
|
+
labels: ["bug", "documentation"],
|
|
522
|
+
token: "gph_YourGitHubToken"
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
]
|
|
526
|
+
})
|
|
527
|
+
}
|
|
528
|
+
];
|
|
529
|
+
|
|
530
|
+
function createGithubIssuesLabelAction(options) {
|
|
531
|
+
const { integrations, githubCredentialsProvider } = options;
|
|
532
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
533
|
+
id: "github:issues:label",
|
|
534
|
+
description: "Adds labels to a pull request or issue on GitHub.",
|
|
535
|
+
examples: examples$7,
|
|
536
|
+
schema: {
|
|
537
|
+
input: {
|
|
538
|
+
type: "object",
|
|
539
|
+
required: ["repoUrl", "number", "labels"],
|
|
540
|
+
properties: {
|
|
541
|
+
repoUrl: {
|
|
542
|
+
title: "Repository Location",
|
|
543
|
+
description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the repository name and 'owner' is an organization or username`,
|
|
544
|
+
type: "string"
|
|
545
|
+
},
|
|
546
|
+
number: {
|
|
547
|
+
title: "Pull Request or issue number",
|
|
548
|
+
description: "The pull request or issue number to add labels to",
|
|
549
|
+
type: "number"
|
|
550
|
+
},
|
|
551
|
+
labels: {
|
|
552
|
+
title: "Labels",
|
|
553
|
+
description: "The labels to add to the pull request or issue",
|
|
554
|
+
type: "array",
|
|
555
|
+
items: {
|
|
556
|
+
type: "string"
|
|
557
|
+
}
|
|
558
|
+
},
|
|
559
|
+
token: {
|
|
560
|
+
title: "Authentication Token",
|
|
561
|
+
type: "string",
|
|
562
|
+
description: "The GITHUB_TOKEN to use for authorization to GitHub"
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
async handler(ctx) {
|
|
568
|
+
const { repoUrl, number, labels, token: providedToken } = ctx.input;
|
|
569
|
+
const { owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
570
|
+
ctx.logger.info(`Adding labels to ${number} issue on repo ${repo}`);
|
|
571
|
+
if (!owner) {
|
|
572
|
+
throw new errors.InputError("Invalid repository owner provided in repoUrl");
|
|
573
|
+
}
|
|
574
|
+
const client = new octokit.Octokit(
|
|
575
|
+
await getOctokitOptions({
|
|
576
|
+
integrations,
|
|
577
|
+
credentialsProvider: githubCredentialsProvider,
|
|
578
|
+
repoUrl,
|
|
579
|
+
token: providedToken
|
|
580
|
+
})
|
|
581
|
+
);
|
|
582
|
+
try {
|
|
583
|
+
await client.rest.issues.addLabels({
|
|
584
|
+
owner,
|
|
585
|
+
repo,
|
|
586
|
+
issue_number: number,
|
|
587
|
+
labels
|
|
588
|
+
});
|
|
589
|
+
} catch (e) {
|
|
590
|
+
errors.assertError(e);
|
|
591
|
+
ctx.logger.warn(
|
|
592
|
+
`Failed: adding labels to issue: '${number}' on repo: '${repo}', ${e.message}`
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
const repoUrl = {
|
|
600
|
+
title: "Repository Location",
|
|
601
|
+
description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,
|
|
602
|
+
type: "string"
|
|
603
|
+
};
|
|
604
|
+
const description = {
|
|
605
|
+
title: "Repository Description",
|
|
606
|
+
type: "string"
|
|
607
|
+
};
|
|
608
|
+
const homepage = {
|
|
609
|
+
title: "Repository Homepage",
|
|
610
|
+
type: "string"
|
|
611
|
+
};
|
|
612
|
+
const access = {
|
|
613
|
+
title: "Repository Access",
|
|
614
|
+
description: `Sets an admin collaborator on the repository. Can either be a user reference different from 'owner' in 'repoUrl' or team reference, eg. 'org/team-name'`,
|
|
615
|
+
type: "string"
|
|
616
|
+
};
|
|
617
|
+
const requireCodeOwnerReviews = {
|
|
618
|
+
title: "Require CODEOWNER Reviews?",
|
|
619
|
+
description: "Require an approved review in PR including files with a designated Code Owner",
|
|
620
|
+
type: "boolean"
|
|
621
|
+
};
|
|
622
|
+
const dismissStaleReviews = {
|
|
623
|
+
title: "Dismiss Stale Reviews",
|
|
624
|
+
description: "New reviewable commits pushed to a matching branch will dismiss pull request review approvals.",
|
|
625
|
+
type: "boolean"
|
|
626
|
+
};
|
|
627
|
+
const requiredStatusCheckContexts = {
|
|
628
|
+
title: "Required Status Check Contexts",
|
|
629
|
+
description: "The list of status checks to require in order to merge into this branch",
|
|
630
|
+
type: "array",
|
|
631
|
+
items: {
|
|
632
|
+
type: "string"
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
const requireBranchesToBeUpToDate = {
|
|
636
|
+
title: "Require Branches To Be Up To Date?",
|
|
637
|
+
description: `Require branches to be up to date before merging. The default value is 'true'`,
|
|
638
|
+
type: "boolean"
|
|
639
|
+
};
|
|
640
|
+
const requiredConversationResolution = {
|
|
641
|
+
title: "Required Conversation Resolution",
|
|
642
|
+
description: "Requires all conversations on code to be resolved before a pull request can be merged into this branch",
|
|
643
|
+
type: "boolean"
|
|
644
|
+
};
|
|
645
|
+
const repoVisibility = {
|
|
646
|
+
title: "Repository Visibility",
|
|
647
|
+
type: "string",
|
|
648
|
+
enum: ["private", "public", "internal"]
|
|
649
|
+
};
|
|
650
|
+
const deleteBranchOnMerge = {
|
|
651
|
+
title: "Delete Branch On Merge",
|
|
652
|
+
type: "boolean",
|
|
653
|
+
description: `Delete the branch after merging the PR. The default value is 'false'`
|
|
654
|
+
};
|
|
655
|
+
const gitAuthorName = {
|
|
656
|
+
title: "Default Author Name",
|
|
657
|
+
type: "string",
|
|
658
|
+
description: `Sets the default author name for the commit. The default value is 'Scaffolder'`
|
|
659
|
+
};
|
|
660
|
+
const gitAuthorEmail = {
|
|
661
|
+
title: "Default Author Email",
|
|
662
|
+
type: "string",
|
|
663
|
+
description: `Sets the default author email for the commit.`
|
|
664
|
+
};
|
|
665
|
+
const allowMergeCommit = {
|
|
666
|
+
title: "Allow Merge Commits",
|
|
667
|
+
type: "boolean",
|
|
668
|
+
description: `Allow merge commits. The default value is 'true'`
|
|
669
|
+
};
|
|
670
|
+
const allowSquashMerge = {
|
|
671
|
+
title: "Allow Squash Merges",
|
|
672
|
+
type: "boolean",
|
|
673
|
+
description: `Allow squash merges. The default value is 'true'`
|
|
674
|
+
};
|
|
675
|
+
const squashMergeCommitTitle = {
|
|
676
|
+
title: "Default squash merge commit title",
|
|
677
|
+
enum: ["PR_TITLE", "COMMIT_OR_PR_TITLE"],
|
|
678
|
+
description: `Sets the default value for a squash merge commit title. The default value is 'COMMIT_OR_PR_TITLE'`
|
|
679
|
+
};
|
|
680
|
+
const squashMergeCommitMessage = {
|
|
681
|
+
title: "Default squash merge commit message",
|
|
682
|
+
enum: ["PR_BODY", "COMMIT_MESSAGES", "BLANK"],
|
|
683
|
+
description: `Sets the default value for a squash merge commit message. The default value is 'COMMIT_MESSAGES'`
|
|
684
|
+
};
|
|
685
|
+
const allowRebaseMerge = {
|
|
686
|
+
title: "Allow Rebase Merges",
|
|
687
|
+
type: "boolean",
|
|
688
|
+
description: `Allow rebase merges. The default value is 'true'`
|
|
689
|
+
};
|
|
690
|
+
const allowAutoMerge = {
|
|
691
|
+
title: "Allow Auto Merges",
|
|
692
|
+
type: "boolean",
|
|
693
|
+
description: `Allow individual PRs to merge automatically when all merge requirements are met. The default value is 'false'`
|
|
694
|
+
};
|
|
695
|
+
const collaborators = {
|
|
696
|
+
title: "Collaborators",
|
|
697
|
+
description: "Provide additional users or teams with permissions",
|
|
698
|
+
type: "array",
|
|
699
|
+
items: {
|
|
700
|
+
type: "object",
|
|
701
|
+
additionalProperties: false,
|
|
702
|
+
required: ["access"],
|
|
703
|
+
properties: {
|
|
704
|
+
access: {
|
|
705
|
+
type: "string",
|
|
706
|
+
description: "The type of access for the user"
|
|
707
|
+
},
|
|
708
|
+
user: {
|
|
709
|
+
type: "string",
|
|
710
|
+
description: "The name of the user that will be added as a collaborator"
|
|
711
|
+
},
|
|
712
|
+
team: {
|
|
713
|
+
type: "string",
|
|
714
|
+
description: "The name of the team that will be added as a collaborator"
|
|
715
|
+
}
|
|
716
|
+
},
|
|
717
|
+
oneOf: [{ required: ["user"] }, { required: ["team"] }]
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
const hasProjects = {
|
|
721
|
+
title: "Enable projects",
|
|
722
|
+
type: "boolean",
|
|
723
|
+
description: `Enable projects for the repository. The default value is 'true' unless the organization has disabled repository projects`
|
|
724
|
+
};
|
|
725
|
+
const hasWiki = {
|
|
726
|
+
title: "Enable the wiki",
|
|
727
|
+
type: "boolean",
|
|
728
|
+
description: `Enable the wiki for the repository. The default value is 'true'`
|
|
729
|
+
};
|
|
730
|
+
const hasIssues = {
|
|
731
|
+
title: "Enable issues",
|
|
732
|
+
type: "boolean",
|
|
733
|
+
description: `Enable issues for the repository. The default value is 'true'`
|
|
734
|
+
};
|
|
735
|
+
const token = {
|
|
736
|
+
title: "Authentication Token",
|
|
737
|
+
type: "string",
|
|
738
|
+
description: "The token to use for authorization to GitHub"
|
|
739
|
+
};
|
|
740
|
+
const topics = {
|
|
741
|
+
title: "Topics",
|
|
742
|
+
type: "array",
|
|
743
|
+
items: {
|
|
744
|
+
type: "string"
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
const defaultBranch = {
|
|
748
|
+
title: "Default Branch",
|
|
749
|
+
type: "string",
|
|
750
|
+
description: `Sets the default branch on the repository. The default value is 'master'`
|
|
751
|
+
};
|
|
752
|
+
const protectDefaultBranch = {
|
|
753
|
+
title: "Protect Default Branch",
|
|
754
|
+
type: "boolean",
|
|
755
|
+
description: `Protect the default branch after creating the repository. The default value is 'true'`
|
|
756
|
+
};
|
|
757
|
+
const protectEnforceAdmins = {
|
|
758
|
+
title: "Enforce Admins On Protected Branches",
|
|
759
|
+
type: "boolean",
|
|
760
|
+
description: `Enforce admins to adhere to default branch protection. The default value is 'true'`
|
|
761
|
+
};
|
|
762
|
+
const bypassPullRequestAllowances = {
|
|
763
|
+
title: "Bypass pull request requirements",
|
|
764
|
+
description: "Allow specific users, teams, or apps to bypass pull request requirements.",
|
|
765
|
+
type: "object",
|
|
766
|
+
additionalProperties: false,
|
|
767
|
+
properties: {
|
|
768
|
+
apps: {
|
|
769
|
+
type: "array",
|
|
770
|
+
items: {
|
|
771
|
+
type: "string"
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
users: {
|
|
775
|
+
type: "array",
|
|
776
|
+
items: {
|
|
777
|
+
type: "string"
|
|
778
|
+
}
|
|
779
|
+
},
|
|
780
|
+
teams: {
|
|
781
|
+
type: "array",
|
|
782
|
+
items: {
|
|
783
|
+
type: "string"
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
const gitCommitMessage = {
|
|
789
|
+
title: "Git Commit Message",
|
|
790
|
+
type: "string",
|
|
791
|
+
description: `Sets the commit message on the repository. The default value is 'initial commit'`
|
|
792
|
+
};
|
|
793
|
+
const sourcePath = {
|
|
794
|
+
title: "Source Path",
|
|
795
|
+
description: "Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.",
|
|
796
|
+
type: "string"
|
|
797
|
+
};
|
|
798
|
+
const requiredApprovingReviewCount = {
|
|
799
|
+
title: "Required approving review count",
|
|
800
|
+
type: "number",
|
|
801
|
+
description: `Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6 or 0 to not require reviewers. Defaults to 1.`
|
|
802
|
+
};
|
|
803
|
+
const restrictions = {
|
|
804
|
+
title: "Restrict who can push to the protected branch",
|
|
805
|
+
description: "Restrict who can push to the protected branch. User, app, and team restrictions are only available for organization-owned repositories.",
|
|
806
|
+
type: "object",
|
|
807
|
+
additionalProperties: false,
|
|
808
|
+
properties: {
|
|
809
|
+
apps: {
|
|
810
|
+
type: "array",
|
|
811
|
+
items: {
|
|
812
|
+
type: "string"
|
|
813
|
+
}
|
|
814
|
+
},
|
|
815
|
+
users: {
|
|
816
|
+
type: "array",
|
|
817
|
+
items: {
|
|
818
|
+
type: "string"
|
|
819
|
+
}
|
|
820
|
+
},
|
|
821
|
+
teams: {
|
|
822
|
+
type: "array",
|
|
823
|
+
items: {
|
|
824
|
+
type: "string"
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
const requiredCommitSigning = {
|
|
830
|
+
title: "Require commit signing",
|
|
831
|
+
type: "boolean",
|
|
832
|
+
description: `Require commit signing so that you must sign commits on this branch.`
|
|
833
|
+
};
|
|
834
|
+
const repoVariables = {
|
|
835
|
+
title: "Repository Variables",
|
|
836
|
+
description: `Variables attached to the repository`,
|
|
837
|
+
type: "object"
|
|
838
|
+
};
|
|
839
|
+
const secrets = {
|
|
840
|
+
title: "Repository Secrets",
|
|
841
|
+
description: `Secrets attached to the repository`,
|
|
842
|
+
type: "object"
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
const remoteUrl = {
|
|
846
|
+
title: "A URL to the repository with the provider",
|
|
847
|
+
type: "string"
|
|
848
|
+
};
|
|
849
|
+
const repoContentsUrl = {
|
|
850
|
+
title: "A URL to the root of the repository",
|
|
851
|
+
type: "string"
|
|
852
|
+
};
|
|
853
|
+
const commitHash = {
|
|
854
|
+
title: "The git commit hash of the initial commit",
|
|
855
|
+
type: "string"
|
|
856
|
+
};
|
|
857
|
+
|
|
858
|
+
const examples$6 = [
|
|
859
|
+
{
|
|
860
|
+
description: "Creates a GitHub repository with default configuration.",
|
|
861
|
+
example: yaml__default["default"].stringify({
|
|
862
|
+
steps: [
|
|
863
|
+
{
|
|
864
|
+
action: "github:repo:create",
|
|
865
|
+
name: "Create a new GitHub repository",
|
|
866
|
+
input: {
|
|
867
|
+
repoUrl: "github.com?repo=repo&owner=owner"
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
]
|
|
871
|
+
})
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
description: "Add a description.",
|
|
875
|
+
example: yaml__default["default"].stringify({
|
|
876
|
+
steps: [
|
|
877
|
+
{
|
|
878
|
+
action: "github:repo:create",
|
|
879
|
+
name: "Create a new GitHub repository with a description",
|
|
880
|
+
input: {
|
|
881
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
882
|
+
description: "My new repository"
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
]
|
|
886
|
+
})
|
|
887
|
+
},
|
|
888
|
+
{
|
|
889
|
+
description: "Disable wiki and issues.",
|
|
890
|
+
example: yaml__default["default"].stringify({
|
|
891
|
+
steps: [
|
|
892
|
+
{
|
|
893
|
+
action: "github:repo:create",
|
|
894
|
+
name: "Create a new GitHub repository without wiki and issues",
|
|
895
|
+
input: {
|
|
896
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
897
|
+
hasIssues: false,
|
|
898
|
+
hasWiki: false
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
]
|
|
902
|
+
})
|
|
903
|
+
}
|
|
904
|
+
];
|
|
905
|
+
|
|
906
|
+
function createGithubRepoCreateAction(options) {
|
|
907
|
+
const { integrations, githubCredentialsProvider } = options;
|
|
908
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
909
|
+
id: "github:repo:create",
|
|
910
|
+
description: "Creates a GitHub repository.",
|
|
911
|
+
examples: examples$6,
|
|
912
|
+
schema: {
|
|
913
|
+
input: {
|
|
914
|
+
type: "object",
|
|
915
|
+
required: ["repoUrl"],
|
|
916
|
+
properties: {
|
|
917
|
+
repoUrl: repoUrl,
|
|
918
|
+
description: description,
|
|
919
|
+
homepage: homepage,
|
|
920
|
+
access: access,
|
|
921
|
+
requireCodeOwnerReviews: requireCodeOwnerReviews,
|
|
922
|
+
bypassPullRequestAllowances: bypassPullRequestAllowances,
|
|
923
|
+
requiredApprovingReviewCount: requiredApprovingReviewCount,
|
|
924
|
+
restrictions: restrictions,
|
|
925
|
+
requiredStatusCheckContexts: requiredStatusCheckContexts,
|
|
926
|
+
requireBranchesToBeUpToDate: requireBranchesToBeUpToDate,
|
|
927
|
+
requiredConversationResolution: requiredConversationResolution,
|
|
928
|
+
repoVisibility: repoVisibility,
|
|
929
|
+
deleteBranchOnMerge: deleteBranchOnMerge,
|
|
930
|
+
allowMergeCommit: allowMergeCommit,
|
|
931
|
+
allowSquashMerge: allowSquashMerge,
|
|
932
|
+
squashMergeCommitTitle: squashMergeCommitTitle,
|
|
933
|
+
squashMergeCommitMessage: squashMergeCommitMessage,
|
|
934
|
+
allowRebaseMerge: allowRebaseMerge,
|
|
935
|
+
allowAutoMerge: allowAutoMerge,
|
|
936
|
+
collaborators: collaborators,
|
|
937
|
+
hasProjects: hasProjects,
|
|
938
|
+
hasWiki: hasWiki,
|
|
939
|
+
hasIssues: hasIssues,
|
|
940
|
+
token: token,
|
|
941
|
+
topics: topics,
|
|
942
|
+
repoVariables: repoVariables,
|
|
943
|
+
secrets: secrets,
|
|
944
|
+
requiredCommitSigning: requiredCommitSigning
|
|
945
|
+
}
|
|
946
|
+
},
|
|
947
|
+
output: {
|
|
948
|
+
type: "object",
|
|
949
|
+
properties: {
|
|
950
|
+
remoteUrl: remoteUrl,
|
|
951
|
+
repoContentsUrl: repoContentsUrl
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
},
|
|
955
|
+
async handler(ctx) {
|
|
956
|
+
const {
|
|
957
|
+
repoUrl,
|
|
958
|
+
description,
|
|
959
|
+
homepage,
|
|
960
|
+
access,
|
|
961
|
+
repoVisibility = "private",
|
|
962
|
+
deleteBranchOnMerge = false,
|
|
963
|
+
allowMergeCommit = true,
|
|
964
|
+
allowSquashMerge = true,
|
|
965
|
+
squashMergeCommitTitle = "COMMIT_OR_PR_TITLE",
|
|
966
|
+
squashMergeCommitMessage = "COMMIT_MESSAGES",
|
|
967
|
+
allowRebaseMerge = true,
|
|
968
|
+
allowAutoMerge = false,
|
|
969
|
+
collaborators,
|
|
970
|
+
hasProjects = void 0,
|
|
971
|
+
hasWiki = void 0,
|
|
972
|
+
hasIssues = void 0,
|
|
973
|
+
topics,
|
|
974
|
+
repoVariables,
|
|
975
|
+
secrets,
|
|
976
|
+
token: providedToken
|
|
977
|
+
} = ctx.input;
|
|
978
|
+
const octokitOptions = await getOctokitOptions({
|
|
979
|
+
integrations,
|
|
980
|
+
credentialsProvider: githubCredentialsProvider,
|
|
981
|
+
token: providedToken,
|
|
982
|
+
repoUrl
|
|
983
|
+
});
|
|
984
|
+
const client = new octokit.Octokit(octokitOptions);
|
|
985
|
+
const { owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
986
|
+
if (!owner) {
|
|
987
|
+
throw new errors.InputError("Invalid repository owner provided in repoUrl");
|
|
988
|
+
}
|
|
989
|
+
const newRepo = await createGithubRepoWithCollaboratorsAndTopics(
|
|
990
|
+
client,
|
|
991
|
+
repo,
|
|
992
|
+
owner,
|
|
993
|
+
repoVisibility,
|
|
994
|
+
description,
|
|
995
|
+
homepage,
|
|
996
|
+
deleteBranchOnMerge,
|
|
997
|
+
allowMergeCommit,
|
|
998
|
+
allowSquashMerge,
|
|
999
|
+
squashMergeCommitTitle,
|
|
1000
|
+
squashMergeCommitMessage,
|
|
1001
|
+
allowRebaseMerge,
|
|
1002
|
+
allowAutoMerge,
|
|
1003
|
+
access,
|
|
1004
|
+
collaborators,
|
|
1005
|
+
hasProjects,
|
|
1006
|
+
hasWiki,
|
|
1007
|
+
hasIssues,
|
|
1008
|
+
topics,
|
|
1009
|
+
repoVariables,
|
|
1010
|
+
secrets,
|
|
1011
|
+
ctx.logger
|
|
1012
|
+
);
|
|
1013
|
+
ctx.output("remoteUrl", newRepo.clone_url);
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
const examples$5 = [
|
|
1019
|
+
{
|
|
1020
|
+
description: "Setup repo with no modifications to branch protection rules",
|
|
1021
|
+
example: yaml__default["default"].stringify({
|
|
1022
|
+
steps: [
|
|
1023
|
+
{
|
|
1024
|
+
action: "github:repo:push",
|
|
1025
|
+
name: "Create test repo with testuser as owner.",
|
|
1026
|
+
input: {
|
|
1027
|
+
repoUrl: "github.com?repo=test&owner=testuser"
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
]
|
|
1031
|
+
})
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
description: "Setup repo with required codeowners check",
|
|
1035
|
+
example: yaml__default["default"].stringify({
|
|
1036
|
+
steps: [
|
|
1037
|
+
{
|
|
1038
|
+
action: "github:repo:push",
|
|
1039
|
+
name: "Require codeowner branch protection rule",
|
|
1040
|
+
input: {
|
|
1041
|
+
repoUrl: "github.com?repo=reponame&owner=owner",
|
|
1042
|
+
requireCodeOwnerReviews: true
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
]
|
|
1046
|
+
})
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
description: "Change the default required number of approvals",
|
|
1050
|
+
example: yaml__default["default"].stringify({
|
|
1051
|
+
steps: [
|
|
1052
|
+
{
|
|
1053
|
+
action: "github:repo:push",
|
|
1054
|
+
name: "Require two approvals before merging",
|
|
1055
|
+
input: {
|
|
1056
|
+
repoUrl: "github.com?repo=reponame&owner=owner",
|
|
1057
|
+
requiredApprovingReviewCount: 2
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
]
|
|
1061
|
+
})
|
|
1062
|
+
}
|
|
1063
|
+
];
|
|
1064
|
+
|
|
1065
|
+
function createGithubRepoPushAction(options) {
|
|
1066
|
+
const { integrations, config, githubCredentialsProvider } = options;
|
|
1067
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
1068
|
+
id: "github:repo:push",
|
|
1069
|
+
description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
|
|
1070
|
+
examples: examples$5,
|
|
1071
|
+
schema: {
|
|
1072
|
+
input: {
|
|
1073
|
+
type: "object",
|
|
1074
|
+
required: ["repoUrl"],
|
|
1075
|
+
properties: {
|
|
1076
|
+
repoUrl: repoUrl,
|
|
1077
|
+
requireCodeOwnerReviews: requireCodeOwnerReviews,
|
|
1078
|
+
dismissStaleReviews: dismissStaleReviews,
|
|
1079
|
+
requiredStatusCheckContexts: requiredStatusCheckContexts,
|
|
1080
|
+
bypassPullRequestAllowances: bypassPullRequestAllowances,
|
|
1081
|
+
requiredApprovingReviewCount: requiredApprovingReviewCount,
|
|
1082
|
+
restrictions: restrictions,
|
|
1083
|
+
requireBranchesToBeUpToDate: requireBranchesToBeUpToDate,
|
|
1084
|
+
requiredConversationResolution: requiredConversationResolution,
|
|
1085
|
+
defaultBranch: defaultBranch,
|
|
1086
|
+
protectDefaultBranch: protectDefaultBranch,
|
|
1087
|
+
protectEnforceAdmins: protectEnforceAdmins,
|
|
1088
|
+
gitCommitMessage: gitCommitMessage,
|
|
1089
|
+
gitAuthorName: gitAuthorName,
|
|
1090
|
+
gitAuthorEmail: gitAuthorEmail,
|
|
1091
|
+
sourcePath: sourcePath,
|
|
1092
|
+
token: token,
|
|
1093
|
+
requiredCommitSigning: requiredCommitSigning
|
|
1094
|
+
}
|
|
1095
|
+
},
|
|
1096
|
+
output: {
|
|
1097
|
+
type: "object",
|
|
1098
|
+
properties: {
|
|
1099
|
+
remoteUrl: remoteUrl,
|
|
1100
|
+
repoContentsUrl: repoContentsUrl,
|
|
1101
|
+
commitHash: commitHash
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
},
|
|
1105
|
+
async handler(ctx) {
|
|
1106
|
+
const {
|
|
1107
|
+
repoUrl,
|
|
1108
|
+
defaultBranch = "master",
|
|
1109
|
+
protectDefaultBranch = true,
|
|
1110
|
+
protectEnforceAdmins = true,
|
|
1111
|
+
gitCommitMessage = "initial commit",
|
|
1112
|
+
gitAuthorName,
|
|
1113
|
+
gitAuthorEmail,
|
|
1114
|
+
requireCodeOwnerReviews = false,
|
|
1115
|
+
dismissStaleReviews = false,
|
|
1116
|
+
bypassPullRequestAllowances,
|
|
1117
|
+
requiredApprovingReviewCount = 1,
|
|
1118
|
+
restrictions,
|
|
1119
|
+
requiredStatusCheckContexts = [],
|
|
1120
|
+
requireBranchesToBeUpToDate = true,
|
|
1121
|
+
requiredConversationResolution = false,
|
|
1122
|
+
token: providedToken,
|
|
1123
|
+
requiredCommitSigning = false
|
|
1124
|
+
} = ctx.input;
|
|
1125
|
+
const { owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
1126
|
+
if (!owner) {
|
|
1127
|
+
throw new errors.InputError("Invalid repository owner provided in repoUrl");
|
|
1128
|
+
}
|
|
1129
|
+
const octokitOptions = await getOctokitOptions({
|
|
1130
|
+
integrations,
|
|
1131
|
+
credentialsProvider: githubCredentialsProvider,
|
|
1132
|
+
token: providedToken,
|
|
1133
|
+
repoUrl
|
|
1134
|
+
});
|
|
1135
|
+
const client = new octokit.Octokit(octokitOptions);
|
|
1136
|
+
const targetRepo = await client.rest.repos.get({ owner, repo });
|
|
1137
|
+
const remoteUrl = targetRepo.data.clone_url;
|
|
1138
|
+
const repoContentsUrl = `${targetRepo.data.html_url}/blob/${defaultBranch}`;
|
|
1139
|
+
const { commitHash } = await initRepoPushAndProtect(
|
|
1140
|
+
remoteUrl,
|
|
1141
|
+
octokitOptions.auth,
|
|
1142
|
+
ctx.workspacePath,
|
|
1143
|
+
ctx.input.sourcePath,
|
|
1144
|
+
defaultBranch,
|
|
1145
|
+
protectDefaultBranch,
|
|
1146
|
+
protectEnforceAdmins,
|
|
1147
|
+
owner,
|
|
1148
|
+
client,
|
|
1149
|
+
repo,
|
|
1150
|
+
requireCodeOwnerReviews,
|
|
1151
|
+
bypassPullRequestAllowances,
|
|
1152
|
+
requiredApprovingReviewCount,
|
|
1153
|
+
restrictions,
|
|
1154
|
+
requiredStatusCheckContexts,
|
|
1155
|
+
requireBranchesToBeUpToDate,
|
|
1156
|
+
requiredConversationResolution,
|
|
1157
|
+
config,
|
|
1158
|
+
ctx.logger,
|
|
1159
|
+
gitCommitMessage,
|
|
1160
|
+
gitAuthorName,
|
|
1161
|
+
gitAuthorEmail,
|
|
1162
|
+
dismissStaleReviews,
|
|
1163
|
+
requiredCommitSigning
|
|
1164
|
+
);
|
|
1165
|
+
ctx.output("remoteUrl", remoteUrl);
|
|
1166
|
+
ctx.output("repoContentsUrl", repoContentsUrl);
|
|
1167
|
+
ctx.output("commitHash", commitHash);
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
const examples$4 = [
|
|
1173
|
+
{
|
|
1174
|
+
description: "Create a GitHub webhook for a repository",
|
|
1175
|
+
example: yaml__default["default"].stringify({
|
|
1176
|
+
steps: [
|
|
1177
|
+
{
|
|
1178
|
+
action: "github:webhook",
|
|
1179
|
+
name: "Create GitHub Webhook",
|
|
1180
|
+
input: {
|
|
1181
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1182
|
+
webhookUrl: "https://example.com/my-webhook",
|
|
1183
|
+
webhookSecret: "mysecret",
|
|
1184
|
+
events: ["push"],
|
|
1185
|
+
active: true,
|
|
1186
|
+
contentType: "json",
|
|
1187
|
+
insecureSsl: false,
|
|
1188
|
+
token: "my-github-token"
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
]
|
|
1192
|
+
})
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
description: "Create a GitHub webhook with minimal configuration",
|
|
1196
|
+
example: yaml__default["default"].stringify({
|
|
1197
|
+
steps: [
|
|
1198
|
+
{
|
|
1199
|
+
action: "github:webhook",
|
|
1200
|
+
name: "Create GitHub Webhook",
|
|
1201
|
+
input: {
|
|
1202
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1203
|
+
webhookUrl: "https://example.com/my-webhook"
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
]
|
|
1207
|
+
})
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
description: "Create a GitHub webhook with custom events",
|
|
1211
|
+
example: yaml__default["default"].stringify({
|
|
1212
|
+
steps: [
|
|
1213
|
+
{
|
|
1214
|
+
action: "github:webhook",
|
|
1215
|
+
name: "Create GitHub Webhook",
|
|
1216
|
+
input: {
|
|
1217
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1218
|
+
webhookUrl: "https://example.com/my-webhook",
|
|
1219
|
+
events: ["push", "pull_request"]
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
]
|
|
1223
|
+
})
|
|
1224
|
+
},
|
|
1225
|
+
{
|
|
1226
|
+
description: "Create a GitHub webhook with JSON content type",
|
|
1227
|
+
example: yaml__default["default"].stringify({
|
|
1228
|
+
steps: [
|
|
1229
|
+
{
|
|
1230
|
+
action: "github:webhook",
|
|
1231
|
+
name: "Create GitHub Webhook",
|
|
1232
|
+
input: {
|
|
1233
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1234
|
+
webhookUrl: "https://example.com/my-webhook",
|
|
1235
|
+
contentType: "json"
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
]
|
|
1239
|
+
})
|
|
1240
|
+
},
|
|
1241
|
+
{
|
|
1242
|
+
description: "Create a GitHub webhook with insecure SSL",
|
|
1243
|
+
example: yaml__default["default"].stringify({
|
|
1244
|
+
steps: [
|
|
1245
|
+
{
|
|
1246
|
+
action: "github:webhook",
|
|
1247
|
+
name: "Create GitHub Webhook",
|
|
1248
|
+
input: {
|
|
1249
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1250
|
+
webhookUrl: "https://example.com/my-webhook",
|
|
1251
|
+
insecureSsl: true
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
]
|
|
1255
|
+
})
|
|
1256
|
+
},
|
|
1257
|
+
{
|
|
1258
|
+
description: "Create an inactive GitHub webhook",
|
|
1259
|
+
example: yaml__default["default"].stringify({
|
|
1260
|
+
steps: [
|
|
1261
|
+
{
|
|
1262
|
+
action: "github:webhook",
|
|
1263
|
+
name: "Create GitHub Webhook",
|
|
1264
|
+
input: {
|
|
1265
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1266
|
+
webhookUrl: "https://example.com/my-webhook",
|
|
1267
|
+
active: false
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
]
|
|
1271
|
+
})
|
|
1272
|
+
}
|
|
1273
|
+
];
|
|
1274
|
+
|
|
1275
|
+
function createGithubWebhookAction(options) {
|
|
1276
|
+
const { integrations, defaultWebhookSecret, githubCredentialsProvider } = options;
|
|
1277
|
+
const eventNames = webhooks.emitterEventNames.filter((event) => !event.includes("."));
|
|
1278
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
1279
|
+
id: "github:webhook",
|
|
1280
|
+
description: "Creates webhook for a repository on GitHub.",
|
|
1281
|
+
examples: examples$4,
|
|
1282
|
+
schema: {
|
|
1283
|
+
input: {
|
|
1284
|
+
type: "object",
|
|
1285
|
+
required: ["repoUrl", "webhookUrl"],
|
|
1286
|
+
properties: {
|
|
1287
|
+
repoUrl: {
|
|
1288
|
+
title: "Repository Location",
|
|
1289
|
+
description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,
|
|
1290
|
+
type: "string"
|
|
1291
|
+
},
|
|
1292
|
+
webhookUrl: {
|
|
1293
|
+
title: "Webhook URL",
|
|
1294
|
+
description: "The URL to which the payloads will be delivered",
|
|
1295
|
+
type: "string"
|
|
1296
|
+
},
|
|
1297
|
+
webhookSecret: {
|
|
1298
|
+
title: "Webhook Secret",
|
|
1299
|
+
description: "Webhook secret value. The default can be provided internally in action creation",
|
|
1300
|
+
type: "string"
|
|
1301
|
+
},
|
|
1302
|
+
events: {
|
|
1303
|
+
title: "Triggering Events",
|
|
1304
|
+
description: "Determines what events the hook is triggered for. Default: push",
|
|
1305
|
+
type: "array",
|
|
1306
|
+
oneOf: [
|
|
1307
|
+
{
|
|
1308
|
+
items: {
|
|
1309
|
+
type: "string",
|
|
1310
|
+
enum: eventNames
|
|
1311
|
+
}
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
items: {
|
|
1315
|
+
type: "string",
|
|
1316
|
+
const: "*"
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
]
|
|
1320
|
+
},
|
|
1321
|
+
active: {
|
|
1322
|
+
title: "Active",
|
|
1323
|
+
type: "boolean",
|
|
1324
|
+
description: `Determines if notifications are sent when the webhook is triggered. Default: true`
|
|
1325
|
+
},
|
|
1326
|
+
contentType: {
|
|
1327
|
+
title: "Content Type",
|
|
1328
|
+
type: "string",
|
|
1329
|
+
enum: ["form", "json"],
|
|
1330
|
+
description: `The media type used to serialize the payloads. The default is 'form'`
|
|
1331
|
+
},
|
|
1332
|
+
insecureSsl: {
|
|
1333
|
+
title: "Insecure SSL",
|
|
1334
|
+
type: "boolean",
|
|
1335
|
+
description: `Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Default 'false'`
|
|
1336
|
+
},
|
|
1337
|
+
token: {
|
|
1338
|
+
title: "Authentication Token",
|
|
1339
|
+
type: "string",
|
|
1340
|
+
description: "The GITHUB_TOKEN to use for authorization to GitHub"
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
},
|
|
1345
|
+
async handler(ctx) {
|
|
1346
|
+
const {
|
|
1347
|
+
repoUrl,
|
|
1348
|
+
webhookUrl,
|
|
1349
|
+
webhookSecret = defaultWebhookSecret,
|
|
1350
|
+
events = ["push"],
|
|
1351
|
+
active = true,
|
|
1352
|
+
contentType = "form",
|
|
1353
|
+
insecureSsl = false,
|
|
1354
|
+
token: providedToken
|
|
1355
|
+
} = ctx.input;
|
|
1356
|
+
ctx.logger.info(`Creating webhook ${webhookUrl} for repo ${repoUrl}`);
|
|
1357
|
+
const { owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
1358
|
+
if (!owner) {
|
|
1359
|
+
throw new errors.InputError("Invalid repository owner provided in repoUrl");
|
|
1360
|
+
}
|
|
1361
|
+
const client = new octokit.Octokit(
|
|
1362
|
+
await getOctokitOptions({
|
|
1363
|
+
integrations,
|
|
1364
|
+
credentialsProvider: githubCredentialsProvider,
|
|
1365
|
+
repoUrl,
|
|
1366
|
+
token: providedToken
|
|
1367
|
+
})
|
|
1368
|
+
);
|
|
1369
|
+
try {
|
|
1370
|
+
const insecure_ssl = insecureSsl ? "1" : "0";
|
|
1371
|
+
await client.rest.repos.createWebhook({
|
|
1372
|
+
owner,
|
|
1373
|
+
repo,
|
|
1374
|
+
config: {
|
|
1375
|
+
url: webhookUrl,
|
|
1376
|
+
content_type: contentType,
|
|
1377
|
+
secret: webhookSecret,
|
|
1378
|
+
insecure_ssl
|
|
1379
|
+
},
|
|
1380
|
+
events,
|
|
1381
|
+
active
|
|
1382
|
+
});
|
|
1383
|
+
ctx.logger.info(`Webhook '${webhookUrl}' created successfully`);
|
|
1384
|
+
} catch (e) {
|
|
1385
|
+
errors.assertError(e);
|
|
1386
|
+
ctx.logger.warn(
|
|
1387
|
+
`Failed: create webhook '${webhookUrl}' on repo: '${repo}', ${e.message}`
|
|
1388
|
+
);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
const examples$3 = [
|
|
1395
|
+
{
|
|
1396
|
+
description: "Example 1: Create and store a Deploy Key",
|
|
1397
|
+
example: yaml__default["default"].stringify({
|
|
1398
|
+
steps: [
|
|
1399
|
+
{
|
|
1400
|
+
action: "github:deployKey:create",
|
|
1401
|
+
name: "Create and store a Deploy Key",
|
|
1402
|
+
input: {
|
|
1403
|
+
repoUrl: "github.com?repo=repository&owner=owner",
|
|
1404
|
+
publicKey: "pubkey",
|
|
1405
|
+
privateKey: "privkey",
|
|
1406
|
+
deployKeyName: "Push Tags"
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
]
|
|
1410
|
+
})
|
|
1411
|
+
}
|
|
1412
|
+
];
|
|
1413
|
+
|
|
1414
|
+
function createGithubDeployKeyAction(options) {
|
|
1415
|
+
const { integrations } = options;
|
|
1416
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
1417
|
+
id: "github:deployKey:create",
|
|
1418
|
+
description: "Creates and stores Deploy Keys",
|
|
1419
|
+
examples: examples$3,
|
|
1420
|
+
schema: {
|
|
1421
|
+
input: {
|
|
1422
|
+
type: "object",
|
|
1423
|
+
required: ["repoUrl", "publicKey", "privateKey", "deployKeyName"],
|
|
1424
|
+
properties: {
|
|
1425
|
+
repoUrl: {
|
|
1426
|
+
title: "Repository Location",
|
|
1427
|
+
description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,
|
|
1428
|
+
type: "string"
|
|
1429
|
+
},
|
|
1430
|
+
publicKey: {
|
|
1431
|
+
title: "SSH Public Key",
|
|
1432
|
+
description: `Generated from ssh-keygen. Begins with 'ssh-rsa', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521', 'ssh-ed25519', 'sk-ecdsa-sha2-nistp256@openssh.com', or 'sk-ssh-ed25519@openssh.com'.`,
|
|
1433
|
+
type: "string"
|
|
1434
|
+
},
|
|
1435
|
+
privateKey: {
|
|
1436
|
+
title: "SSH Private Key",
|
|
1437
|
+
description: `SSH Private Key generated from ssh-keygen`,
|
|
1438
|
+
type: "string"
|
|
1439
|
+
},
|
|
1440
|
+
deployKeyName: {
|
|
1441
|
+
title: "Deploy Key Name",
|
|
1442
|
+
description: `Name of the Deploy Key`,
|
|
1443
|
+
type: "string"
|
|
1444
|
+
},
|
|
1445
|
+
privateKeySecretName: {
|
|
1446
|
+
title: "Private Key GitHub Secret Name",
|
|
1447
|
+
description: `Name of the GitHub Secret to store the private key related to the Deploy Key. Defaults to: 'KEY_NAME_PRIVATE_KEY' where 'KEY_NAME' is the name of the Deploy Key`,
|
|
1448
|
+
type: "string"
|
|
1449
|
+
},
|
|
1450
|
+
token: {
|
|
1451
|
+
title: "Authentication Token",
|
|
1452
|
+
type: "string",
|
|
1453
|
+
description: "The token to use for authorization to GitHub"
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
},
|
|
1457
|
+
output: {
|
|
1458
|
+
type: "object",
|
|
1459
|
+
properties: {
|
|
1460
|
+
privateKeySecretName: {
|
|
1461
|
+
title: "The GitHub Action Repo Secret Name for the Private Key",
|
|
1462
|
+
type: "string"
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
},
|
|
1467
|
+
async handler(ctx) {
|
|
1468
|
+
const {
|
|
1469
|
+
repoUrl,
|
|
1470
|
+
publicKey,
|
|
1471
|
+
privateKey,
|
|
1472
|
+
deployKeyName,
|
|
1473
|
+
privateKeySecretName = `${deployKeyName.split(" ").join("_").toLocaleUpperCase("en-US")}_PRIVATE_KEY`,
|
|
1474
|
+
token: providedToken
|
|
1475
|
+
} = ctx.input;
|
|
1476
|
+
const octokitOptions = await getOctokitOptions({
|
|
1477
|
+
integrations,
|
|
1478
|
+
token: providedToken,
|
|
1479
|
+
repoUrl
|
|
1480
|
+
});
|
|
1481
|
+
const { owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
1482
|
+
if (!owner) {
|
|
1483
|
+
throw new errors.InputError(`No owner provided for repo ${repoUrl}`);
|
|
1484
|
+
}
|
|
1485
|
+
const client = new octokit.Octokit(octokitOptions);
|
|
1486
|
+
await client.rest.repos.createDeployKey({
|
|
1487
|
+
owner,
|
|
1488
|
+
repo,
|
|
1489
|
+
title: deployKeyName,
|
|
1490
|
+
key: publicKey
|
|
1491
|
+
});
|
|
1492
|
+
const publicKeyResponse = await client.rest.actions.getRepoPublicKey({
|
|
1493
|
+
owner,
|
|
1494
|
+
repo
|
|
1495
|
+
});
|
|
1496
|
+
await Sodium__default["default"].ready;
|
|
1497
|
+
const binaryKey = Sodium__default["default"].from_base64(
|
|
1498
|
+
publicKeyResponse.data.key,
|
|
1499
|
+
Sodium__default["default"].base64_variants.ORIGINAL
|
|
1500
|
+
);
|
|
1501
|
+
const binarySecret = Sodium__default["default"].from_string(privateKey);
|
|
1502
|
+
const encryptedBinarySecret = Sodium__default["default"].crypto_box_seal(
|
|
1503
|
+
binarySecret,
|
|
1504
|
+
binaryKey
|
|
1505
|
+
);
|
|
1506
|
+
const encryptedBase64Secret = Sodium__default["default"].to_base64(
|
|
1507
|
+
encryptedBinarySecret,
|
|
1508
|
+
Sodium__default["default"].base64_variants.ORIGINAL
|
|
1509
|
+
);
|
|
1510
|
+
await client.rest.actions.createOrUpdateRepoSecret({
|
|
1511
|
+
owner,
|
|
1512
|
+
repo,
|
|
1513
|
+
secret_name: privateKeySecretName,
|
|
1514
|
+
encrypted_value: encryptedBase64Secret,
|
|
1515
|
+
key_id: publicKeyResponse.data.key_id
|
|
1516
|
+
});
|
|
1517
|
+
ctx.output("privateKeySecretName", privateKeySecretName);
|
|
1518
|
+
}
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
const examples$2 = [
|
|
1523
|
+
{
|
|
1524
|
+
description: "Create a GitHub Environment (No Policies, No Variables, No Secrets)",
|
|
1525
|
+
example: yaml__default["default"].stringify({
|
|
1526
|
+
steps: [
|
|
1527
|
+
{
|
|
1528
|
+
action: "github:environment:create",
|
|
1529
|
+
name: "Create Environment",
|
|
1530
|
+
input: {
|
|
1531
|
+
repoUrl: "github.com?repo=repository&owner=owner",
|
|
1532
|
+
name: "envname"
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
]
|
|
1536
|
+
})
|
|
1537
|
+
},
|
|
1538
|
+
{
|
|
1539
|
+
description: "Create a GitHub Environment with Protected Branch Policy",
|
|
1540
|
+
example: yaml__default["default"].stringify({
|
|
1541
|
+
steps: [
|
|
1542
|
+
{
|
|
1543
|
+
action: "github:environment:create",
|
|
1544
|
+
name: "Create Environment",
|
|
1545
|
+
input: {
|
|
1546
|
+
repoUrl: "github.com?repo=repository&owner=owner",
|
|
1547
|
+
name: "envname",
|
|
1548
|
+
deploymentBranchPolicy: {
|
|
1549
|
+
protected_branches: true,
|
|
1550
|
+
custom_branch_policies: false
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
]
|
|
1555
|
+
})
|
|
1556
|
+
},
|
|
1557
|
+
{
|
|
1558
|
+
description: "Create a GitHub Environment with Custom Branch Policies",
|
|
1559
|
+
example: yaml__default["default"].stringify({
|
|
1560
|
+
steps: [
|
|
1561
|
+
{
|
|
1562
|
+
action: "github:environment:create",
|
|
1563
|
+
name: "Create Environment",
|
|
1564
|
+
input: {
|
|
1565
|
+
repoUrl: "github.com?repo=repository&owner=owner",
|
|
1566
|
+
name: "envname",
|
|
1567
|
+
deploymentBranchPolicy: {
|
|
1568
|
+
protected_branches: false,
|
|
1569
|
+
custom_branch_policies: true
|
|
1570
|
+
},
|
|
1571
|
+
customBranchPolicyNames: ["main", "*.*.*"]
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
]
|
|
1575
|
+
})
|
|
1576
|
+
},
|
|
1577
|
+
{
|
|
1578
|
+
description: "Create a GitHub Environment with Environment Variables and Secrets",
|
|
1579
|
+
example: yaml__default["default"].stringify({
|
|
1580
|
+
steps: [
|
|
1581
|
+
{
|
|
1582
|
+
action: "github:environment:create",
|
|
1583
|
+
name: "Create Environment",
|
|
1584
|
+
input: {
|
|
1585
|
+
repoUrl: "github.com?repo=repository&owner=owner",
|
|
1586
|
+
name: "envname",
|
|
1587
|
+
environmentVariables: {
|
|
1588
|
+
key1: "val1",
|
|
1589
|
+
key2: "val2"
|
|
1590
|
+
},
|
|
1591
|
+
secrets: {
|
|
1592
|
+
secret1: "supersecret1",
|
|
1593
|
+
secret2: "supersecret2"
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
]
|
|
1598
|
+
})
|
|
1599
|
+
}
|
|
1600
|
+
];
|
|
1601
|
+
|
|
1602
|
+
function createGithubEnvironmentAction(options) {
|
|
1603
|
+
const { integrations } = options;
|
|
1604
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
1605
|
+
id: "github:environment:create",
|
|
1606
|
+
description: "Creates Deployment Environments",
|
|
1607
|
+
examples: examples$2,
|
|
1608
|
+
schema: {
|
|
1609
|
+
input: {
|
|
1610
|
+
type: "object",
|
|
1611
|
+
required: ["repoUrl", "name"],
|
|
1612
|
+
properties: {
|
|
1613
|
+
repoUrl: {
|
|
1614
|
+
title: "Repository Location",
|
|
1615
|
+
description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,
|
|
1616
|
+
type: "string"
|
|
1617
|
+
},
|
|
1618
|
+
name: {
|
|
1619
|
+
title: "Environment Name",
|
|
1620
|
+
description: `Name of the deployment environment to create`,
|
|
1621
|
+
type: "string"
|
|
1622
|
+
},
|
|
1623
|
+
deploymentBranchPolicy: {
|
|
1624
|
+
title: "Deployment Branch Policy",
|
|
1625
|
+
description: `The type of deployment branch policy for this environment. To allow all branches to deploy, set to null.`,
|
|
1626
|
+
type: "object",
|
|
1627
|
+
required: ["protected_branches", "custom_branch_policies"],
|
|
1628
|
+
properties: {
|
|
1629
|
+
protected_branches: {
|
|
1630
|
+
title: "Protected Branches",
|
|
1631
|
+
description: `Whether only branches with branch protection rules can deploy to this environment. If protected_branches is true, custom_branch_policies must be false; if protected_branches is false, custom_branch_policies must be true.`,
|
|
1632
|
+
type: "boolean"
|
|
1633
|
+
},
|
|
1634
|
+
custom_branch_policies: {
|
|
1635
|
+
title: "Custom Branch Policies",
|
|
1636
|
+
description: `Whether only branches that match the specified name patterns can deploy to this environment. If custom_branch_policies is true, protected_branches must be false; if custom_branch_policies is false, protected_branches must be true.`,
|
|
1637
|
+
type: "boolean"
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
},
|
|
1641
|
+
customBranchPolicyNames: {
|
|
1642
|
+
title: "Custom Branch Policy Name",
|
|
1643
|
+
description: `The name pattern that branches must match in order to deploy to the environment.
|
|
1644
|
+
|
|
1645
|
+
Wildcard characters will not match /. For example, to match branches that begin with release/ and contain an additional single slash, use release/*/*. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.`,
|
|
1646
|
+
type: "array",
|
|
1647
|
+
items: {
|
|
1648
|
+
type: "string"
|
|
1649
|
+
}
|
|
1650
|
+
},
|
|
1651
|
+
environmentVariables: {
|
|
1652
|
+
title: "Environment Variables",
|
|
1653
|
+
description: `Environment variables attached to the deployment environment`,
|
|
1654
|
+
type: "object"
|
|
1655
|
+
},
|
|
1656
|
+
secrets: {
|
|
1657
|
+
title: "Deployment Secrets",
|
|
1658
|
+
description: `Secrets attached to the deployment environment`,
|
|
1659
|
+
type: "object"
|
|
1660
|
+
},
|
|
1661
|
+
token: {
|
|
1662
|
+
title: "Authentication Token",
|
|
1663
|
+
type: "string",
|
|
1664
|
+
description: "The token to use for authorization to GitHub"
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
},
|
|
1669
|
+
async handler(ctx) {
|
|
1670
|
+
const {
|
|
1671
|
+
repoUrl,
|
|
1672
|
+
name,
|
|
1673
|
+
deploymentBranchPolicy,
|
|
1674
|
+
customBranchPolicyNames,
|
|
1675
|
+
environmentVariables,
|
|
1676
|
+
secrets,
|
|
1677
|
+
token: providedToken
|
|
1678
|
+
} = ctx.input;
|
|
1679
|
+
const octokitOptions = await getOctokitOptions({
|
|
1680
|
+
integrations,
|
|
1681
|
+
token: providedToken,
|
|
1682
|
+
repoUrl
|
|
1683
|
+
});
|
|
1684
|
+
const { owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
1685
|
+
if (!owner) {
|
|
1686
|
+
throw new errors.InputError(`No owner provided for repo ${repoUrl}`);
|
|
1687
|
+
}
|
|
1688
|
+
const client = new octokit.Octokit(octokitOptions);
|
|
1689
|
+
const repository = await client.rest.repos.get({
|
|
1690
|
+
owner,
|
|
1691
|
+
repo
|
|
1692
|
+
});
|
|
1693
|
+
await client.rest.repos.createOrUpdateEnvironment({
|
|
1694
|
+
owner,
|
|
1695
|
+
repo,
|
|
1696
|
+
environment_name: name,
|
|
1697
|
+
deployment_branch_policy: deploymentBranchPolicy != null ? deploymentBranchPolicy : null
|
|
1698
|
+
});
|
|
1699
|
+
if (customBranchPolicyNames) {
|
|
1700
|
+
for (const item of customBranchPolicyNames) {
|
|
1701
|
+
await client.rest.repos.createDeploymentBranchPolicy({
|
|
1702
|
+
owner,
|
|
1703
|
+
repo,
|
|
1704
|
+
environment_name: name,
|
|
1705
|
+
name: item
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
for (const [key, value] of Object.entries(environmentVariables != null ? environmentVariables : {})) {
|
|
1710
|
+
await client.rest.actions.createEnvironmentVariable({
|
|
1711
|
+
repository_id: repository.data.id,
|
|
1712
|
+
environment_name: name,
|
|
1713
|
+
name: key,
|
|
1714
|
+
value
|
|
1715
|
+
});
|
|
1716
|
+
}
|
|
1717
|
+
if (secrets) {
|
|
1718
|
+
const publicKeyResponse = await client.rest.actions.getEnvironmentPublicKey({
|
|
1719
|
+
repository_id: repository.data.id,
|
|
1720
|
+
environment_name: name
|
|
1721
|
+
});
|
|
1722
|
+
await Sodium__default["default"].ready;
|
|
1723
|
+
const binaryKey = Sodium__default["default"].from_base64(
|
|
1724
|
+
publicKeyResponse.data.key,
|
|
1725
|
+
Sodium__default["default"].base64_variants.ORIGINAL
|
|
1726
|
+
);
|
|
1727
|
+
for (const [key, value] of Object.entries(secrets)) {
|
|
1728
|
+
const binarySecret = Sodium__default["default"].from_string(value);
|
|
1729
|
+
const encryptedBinarySecret = Sodium__default["default"].crypto_box_seal(
|
|
1730
|
+
binarySecret,
|
|
1731
|
+
binaryKey
|
|
1732
|
+
);
|
|
1733
|
+
const encryptedBase64Secret = Sodium__default["default"].to_base64(
|
|
1734
|
+
encryptedBinarySecret,
|
|
1735
|
+
Sodium__default["default"].base64_variants.ORIGINAL
|
|
1736
|
+
);
|
|
1737
|
+
await client.rest.actions.createOrUpdateEnvironmentSecret({
|
|
1738
|
+
repository_id: repository.data.id,
|
|
1739
|
+
environment_name: name,
|
|
1740
|
+
secret_name: key,
|
|
1741
|
+
encrypted_value: encryptedBase64Secret,
|
|
1742
|
+
key_id: publicKeyResponse.data.key_id
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
const examples$1 = [
|
|
1751
|
+
{
|
|
1752
|
+
description: "Create a pull request",
|
|
1753
|
+
example: yaml__default["default"].stringify({
|
|
1754
|
+
steps: [
|
|
1755
|
+
{
|
|
1756
|
+
action: "publish:github:pull-request",
|
|
1757
|
+
name: "Create a pull reuqest",
|
|
1758
|
+
input: {
|
|
1759
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1760
|
+
branchName: "new-app",
|
|
1761
|
+
title: "Create my new app",
|
|
1762
|
+
description: "This PR is really good"
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
]
|
|
1766
|
+
})
|
|
1767
|
+
},
|
|
1768
|
+
{
|
|
1769
|
+
description: "Create a pull request with target branch name",
|
|
1770
|
+
example: yaml__default["default"].stringify({
|
|
1771
|
+
steps: [
|
|
1772
|
+
{
|
|
1773
|
+
action: "publish:github:pull-request",
|
|
1774
|
+
name: "Create a pull reuqest with target branch name",
|
|
1775
|
+
input: {
|
|
1776
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1777
|
+
branchName: "new-app",
|
|
1778
|
+
title: "Create my new app",
|
|
1779
|
+
description: "This PR is really good",
|
|
1780
|
+
targetBranchName: "test"
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
]
|
|
1784
|
+
})
|
|
1785
|
+
},
|
|
1786
|
+
{
|
|
1787
|
+
description: "Create a pull request as draft",
|
|
1788
|
+
example: yaml__default["default"].stringify({
|
|
1789
|
+
steps: [
|
|
1790
|
+
{
|
|
1791
|
+
action: "publish:github:pull-request",
|
|
1792
|
+
name: "Create a pull reuqest as draft",
|
|
1793
|
+
input: {
|
|
1794
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1795
|
+
branchName: "new-app",
|
|
1796
|
+
title: "Create my new app",
|
|
1797
|
+
description: "This PR is really good",
|
|
1798
|
+
draft: true
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
]
|
|
1802
|
+
})
|
|
1803
|
+
},
|
|
1804
|
+
{
|
|
1805
|
+
description: "Create a pull request with target path",
|
|
1806
|
+
example: yaml__default["default"].stringify({
|
|
1807
|
+
steps: [
|
|
1808
|
+
{
|
|
1809
|
+
action: "publish:github:pull-request",
|
|
1810
|
+
name: "Create a pull reuqest with target path",
|
|
1811
|
+
input: {
|
|
1812
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1813
|
+
branchName: "new-app",
|
|
1814
|
+
title: "Create my new app",
|
|
1815
|
+
description: "This PR is really good",
|
|
1816
|
+
targetPath: "targetPath"
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
]
|
|
1820
|
+
})
|
|
1821
|
+
},
|
|
1822
|
+
{
|
|
1823
|
+
description: "Create a pull request with source path",
|
|
1824
|
+
example: yaml__default["default"].stringify({
|
|
1825
|
+
steps: [
|
|
1826
|
+
{
|
|
1827
|
+
action: "publish:github:pull-request",
|
|
1828
|
+
name: "Create a pull reuqest with source path",
|
|
1829
|
+
input: {
|
|
1830
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1831
|
+
branchName: "new-app",
|
|
1832
|
+
title: "Create my new app",
|
|
1833
|
+
description: "This PR is really good",
|
|
1834
|
+
sourcePath: "source"
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
]
|
|
1838
|
+
})
|
|
1839
|
+
},
|
|
1840
|
+
{
|
|
1841
|
+
description: "Create a pull request with token",
|
|
1842
|
+
example: yaml__default["default"].stringify({
|
|
1843
|
+
steps: [
|
|
1844
|
+
{
|
|
1845
|
+
action: "publish:github:pull-request",
|
|
1846
|
+
name: "Create a pull reuqest",
|
|
1847
|
+
input: {
|
|
1848
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1849
|
+
branchName: "new-app",
|
|
1850
|
+
title: "Create my new app",
|
|
1851
|
+
description: "This PR is really good",
|
|
1852
|
+
token: "gph_YourGitHubToken"
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
]
|
|
1856
|
+
})
|
|
1857
|
+
},
|
|
1858
|
+
{
|
|
1859
|
+
description: "Create a pull request with reviewers",
|
|
1860
|
+
example: yaml__default["default"].stringify({
|
|
1861
|
+
steps: [
|
|
1862
|
+
{
|
|
1863
|
+
action: "publish:github:pull-request",
|
|
1864
|
+
name: "Create a pull reuqest with reviewers",
|
|
1865
|
+
input: {
|
|
1866
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1867
|
+
branchName: "new-app",
|
|
1868
|
+
title: "Create my new app",
|
|
1869
|
+
description: "This PR is really good",
|
|
1870
|
+
reviewers: ["foobar"]
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
]
|
|
1874
|
+
})
|
|
1875
|
+
},
|
|
1876
|
+
{
|
|
1877
|
+
description: "Create a pull request with team reviewers",
|
|
1878
|
+
example: yaml__default["default"].stringify({
|
|
1879
|
+
steps: [
|
|
1880
|
+
{
|
|
1881
|
+
action: "publish:github:pull-request",
|
|
1882
|
+
name: "Create a pull reuqest with team reviewers",
|
|
1883
|
+
input: {
|
|
1884
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1885
|
+
branchName: "new-app",
|
|
1886
|
+
title: "Create my new app",
|
|
1887
|
+
description: "This PR is really good",
|
|
1888
|
+
teamReviewers: ["team-foo"]
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
]
|
|
1892
|
+
})
|
|
1893
|
+
},
|
|
1894
|
+
{
|
|
1895
|
+
description: "Create a pull request with commit message",
|
|
1896
|
+
example: yaml__default["default"].stringify({
|
|
1897
|
+
steps: [
|
|
1898
|
+
{
|
|
1899
|
+
action: "publish:github:pull-request",
|
|
1900
|
+
name: "Create a pull reuqest",
|
|
1901
|
+
input: {
|
|
1902
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1903
|
+
branchName: "new-app",
|
|
1904
|
+
title: "Create my new app",
|
|
1905
|
+
description: "This PR is really good",
|
|
1906
|
+
commitMessage: "Custom commit message"
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
]
|
|
1910
|
+
})
|
|
1911
|
+
},
|
|
1912
|
+
{
|
|
1913
|
+
description: "Create a pull request with all parameters",
|
|
1914
|
+
example: yaml__default["default"].stringify({
|
|
1915
|
+
steps: [
|
|
1916
|
+
{
|
|
1917
|
+
action: "publish:github:pull-request",
|
|
1918
|
+
name: "Create a pull reuqest",
|
|
1919
|
+
input: {
|
|
1920
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
1921
|
+
branchName: "new-app",
|
|
1922
|
+
title: "Create my new app",
|
|
1923
|
+
description: "This PR is really good",
|
|
1924
|
+
targetBranchName: "test",
|
|
1925
|
+
draft: true,
|
|
1926
|
+
targetPath: "targetPath",
|
|
1927
|
+
sourcePath: "source",
|
|
1928
|
+
token: "gph_YourGitHubToken",
|
|
1929
|
+
reviewers: ["foobar"],
|
|
1930
|
+
teamReviewers: ["team-foo"],
|
|
1931
|
+
commitMessage: "Commit for foo changes"
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
]
|
|
1935
|
+
})
|
|
1936
|
+
}
|
|
1937
|
+
];
|
|
1938
|
+
|
|
1939
|
+
class GithubResponseError extends errors.CustomErrorBase {
|
|
1940
|
+
}
|
|
1941
|
+
const defaultClientFactory = async ({
|
|
1942
|
+
integrations,
|
|
1943
|
+
githubCredentialsProvider,
|
|
1944
|
+
owner,
|
|
1945
|
+
repo,
|
|
1946
|
+
host = "github.com",
|
|
1947
|
+
token: providedToken
|
|
1948
|
+
}) => {
|
|
1949
|
+
const [encodedHost, encodedOwner, encodedRepo] = [host, owner, repo].map(
|
|
1950
|
+
encodeURIComponent
|
|
1951
|
+
);
|
|
1952
|
+
const octokitOptions = await getOctokitOptions({
|
|
1953
|
+
integrations,
|
|
1954
|
+
credentialsProvider: githubCredentialsProvider,
|
|
1955
|
+
repoUrl: `${encodedHost}?owner=${encodedOwner}&repo=${encodedRepo}`,
|
|
1956
|
+
token: providedToken
|
|
1957
|
+
});
|
|
1958
|
+
const OctokitPR = octokit.Octokit.plugin(octokitPluginCreatePullRequest.createPullRequest);
|
|
1959
|
+
return new OctokitPR({
|
|
1960
|
+
...octokitOptions,
|
|
1961
|
+
...{ throttle: { enabled: false } }
|
|
1962
|
+
});
|
|
1963
|
+
};
|
|
1964
|
+
const createPublishGithubPullRequestAction = (options) => {
|
|
1965
|
+
const {
|
|
1966
|
+
integrations,
|
|
1967
|
+
githubCredentialsProvider,
|
|
1968
|
+
clientFactory = defaultClientFactory
|
|
1969
|
+
} = options;
|
|
1970
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
1971
|
+
id: "publish:github:pull-request",
|
|
1972
|
+
examples: examples$1,
|
|
1973
|
+
schema: {
|
|
1974
|
+
input: {
|
|
1975
|
+
required: ["repoUrl", "title", "description", "branchName"],
|
|
1976
|
+
type: "object",
|
|
1977
|
+
properties: {
|
|
1978
|
+
repoUrl: {
|
|
1979
|
+
title: "Repository Location",
|
|
1980
|
+
description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the repository name and 'owner' is an organization or username`,
|
|
1981
|
+
type: "string"
|
|
1982
|
+
},
|
|
1983
|
+
branchName: {
|
|
1984
|
+
type: "string",
|
|
1985
|
+
title: "Branch Name",
|
|
1986
|
+
description: "The name for the branch"
|
|
1987
|
+
},
|
|
1988
|
+
targetBranchName: {
|
|
1989
|
+
type: "string",
|
|
1990
|
+
title: "Target Branch Name",
|
|
1991
|
+
description: "The target branch name of the merge request"
|
|
1992
|
+
},
|
|
1993
|
+
title: {
|
|
1994
|
+
type: "string",
|
|
1995
|
+
title: "Pull Request Name",
|
|
1996
|
+
description: "The name for the pull request"
|
|
1997
|
+
},
|
|
1998
|
+
description: {
|
|
1999
|
+
type: "string",
|
|
2000
|
+
title: "Pull Request Description",
|
|
2001
|
+
description: "The description of the pull request"
|
|
2002
|
+
},
|
|
2003
|
+
draft: {
|
|
2004
|
+
type: "boolean",
|
|
2005
|
+
title: "Create as Draft",
|
|
2006
|
+
description: "Create a draft pull request"
|
|
2007
|
+
},
|
|
2008
|
+
sourcePath: {
|
|
2009
|
+
type: "string",
|
|
2010
|
+
title: "Working Subdirectory",
|
|
2011
|
+
description: "Subdirectory of working directory to copy changes from"
|
|
2012
|
+
},
|
|
2013
|
+
targetPath: {
|
|
2014
|
+
type: "string",
|
|
2015
|
+
title: "Repository Subdirectory",
|
|
2016
|
+
description: "Subdirectory of repository to apply changes to"
|
|
2017
|
+
},
|
|
2018
|
+
token: {
|
|
2019
|
+
title: "Authentication Token",
|
|
2020
|
+
type: "string",
|
|
2021
|
+
description: "The token to use for authorization to GitHub"
|
|
2022
|
+
},
|
|
2023
|
+
reviewers: {
|
|
2024
|
+
title: "Pull Request Reviewers",
|
|
2025
|
+
type: "array",
|
|
2026
|
+
items: {
|
|
2027
|
+
type: "string"
|
|
2028
|
+
},
|
|
2029
|
+
description: "The users that will be added as reviewers to the pull request"
|
|
2030
|
+
},
|
|
2031
|
+
teamReviewers: {
|
|
2032
|
+
title: "Pull Request Team Reviewers",
|
|
2033
|
+
type: "array",
|
|
2034
|
+
items: {
|
|
2035
|
+
type: "string"
|
|
2036
|
+
},
|
|
2037
|
+
description: "The teams that will be added as reviewers to the pull request"
|
|
2038
|
+
},
|
|
2039
|
+
commitMessage: {
|
|
2040
|
+
type: "string",
|
|
2041
|
+
title: "Commit Message",
|
|
2042
|
+
description: "The commit message for the pull request commit"
|
|
2043
|
+
},
|
|
2044
|
+
update: {
|
|
2045
|
+
type: "boolean",
|
|
2046
|
+
title: "Update",
|
|
2047
|
+
description: "Update pull request if already exists"
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
},
|
|
2051
|
+
output: {
|
|
2052
|
+
required: ["remoteUrl"],
|
|
2053
|
+
type: "object",
|
|
2054
|
+
properties: {
|
|
2055
|
+
targetBranchName: {
|
|
2056
|
+
title: "Target branch name of the merge request",
|
|
2057
|
+
type: "string"
|
|
2058
|
+
},
|
|
2059
|
+
remoteUrl: {
|
|
2060
|
+
type: "string",
|
|
2061
|
+
title: "Pull Request URL",
|
|
2062
|
+
description: "Link to the pull request in Github"
|
|
2063
|
+
},
|
|
2064
|
+
pullRequestNumber: {
|
|
2065
|
+
type: "number",
|
|
2066
|
+
title: "Pull Request Number",
|
|
2067
|
+
description: "The pull request number"
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
},
|
|
2072
|
+
async handler(ctx) {
|
|
2073
|
+
const {
|
|
2074
|
+
repoUrl,
|
|
2075
|
+
branchName,
|
|
2076
|
+
targetBranchName,
|
|
2077
|
+
title,
|
|
2078
|
+
description,
|
|
2079
|
+
draft,
|
|
2080
|
+
targetPath,
|
|
2081
|
+
sourcePath,
|
|
2082
|
+
token: providedToken,
|
|
2083
|
+
reviewers,
|
|
2084
|
+
teamReviewers,
|
|
2085
|
+
commitMessage,
|
|
2086
|
+
update
|
|
2087
|
+
} = ctx.input;
|
|
2088
|
+
const { owner, repo, host } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
2089
|
+
if (!owner) {
|
|
2090
|
+
throw new errors.InputError(
|
|
2091
|
+
`No owner provided for host: ${host}, and repo ${repo}`
|
|
2092
|
+
);
|
|
2093
|
+
}
|
|
2094
|
+
const client = await clientFactory({
|
|
2095
|
+
integrations,
|
|
2096
|
+
githubCredentialsProvider,
|
|
2097
|
+
host,
|
|
2098
|
+
owner,
|
|
2099
|
+
repo,
|
|
2100
|
+
token: providedToken
|
|
2101
|
+
});
|
|
2102
|
+
const fileRoot = sourcePath ? backendCommon.resolveSafeChildPath(ctx.workspacePath, sourcePath) : ctx.workspacePath;
|
|
2103
|
+
const directoryContents = await pluginScaffolderNode.serializeDirectoryContents(fileRoot, {
|
|
2104
|
+
gitignore: true
|
|
2105
|
+
});
|
|
2106
|
+
const determineFileMode = (file) => {
|
|
2107
|
+
if (file.symlink)
|
|
2108
|
+
return "120000";
|
|
2109
|
+
if (file.executable)
|
|
2110
|
+
return "100755";
|
|
2111
|
+
return "100644";
|
|
2112
|
+
};
|
|
2113
|
+
const determineFileEncoding = (file) => file.symlink ? "utf-8" : "base64";
|
|
2114
|
+
const files = Object.fromEntries(
|
|
2115
|
+
directoryContents.map((file) => [
|
|
2116
|
+
targetPath ? path__default["default"].posix.join(targetPath, file.path) : file.path,
|
|
2117
|
+
{
|
|
2118
|
+
// See the properties of tree items
|
|
2119
|
+
// in https://docs.github.com/en/rest/reference/git#trees
|
|
2120
|
+
mode: determineFileMode(file),
|
|
2121
|
+
// Always use base64 encoding where possible to avoid doubling a binary file in size
|
|
2122
|
+
// due to interpreting a binary file as utf-8 and sending github
|
|
2123
|
+
// the utf-8 encoded content. Symlinks are kept as utf-8 to avoid them
|
|
2124
|
+
// being formatted as a series of scrambled characters
|
|
2125
|
+
//
|
|
2126
|
+
// For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.
|
|
2127
|
+
// Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)
|
|
2128
|
+
encoding: determineFileEncoding(file),
|
|
2129
|
+
content: file.content.toString(determineFileEncoding(file))
|
|
2130
|
+
}
|
|
2131
|
+
])
|
|
2132
|
+
);
|
|
2133
|
+
try {
|
|
2134
|
+
const createOptions = {
|
|
2135
|
+
owner,
|
|
2136
|
+
repo,
|
|
2137
|
+
title,
|
|
2138
|
+
changes: [
|
|
2139
|
+
{
|
|
2140
|
+
files,
|
|
2141
|
+
commit: commitMessage != null ? commitMessage : title
|
|
2142
|
+
}
|
|
2143
|
+
],
|
|
2144
|
+
body: description,
|
|
2145
|
+
head: branchName,
|
|
2146
|
+
draft,
|
|
2147
|
+
update
|
|
2148
|
+
};
|
|
2149
|
+
if (targetBranchName) {
|
|
2150
|
+
createOptions.base = targetBranchName;
|
|
2151
|
+
}
|
|
2152
|
+
const response = await client.createPullRequest(createOptions);
|
|
2153
|
+
if (!response) {
|
|
2154
|
+
throw new GithubResponseError("null response from Github");
|
|
2155
|
+
}
|
|
2156
|
+
const pullRequestNumber = response.data.number;
|
|
2157
|
+
if (reviewers || teamReviewers) {
|
|
2158
|
+
const pullRequest = { owner, repo, number: pullRequestNumber };
|
|
2159
|
+
await requestReviewersOnPullRequest(
|
|
2160
|
+
pullRequest,
|
|
2161
|
+
reviewers,
|
|
2162
|
+
teamReviewers,
|
|
2163
|
+
client,
|
|
2164
|
+
ctx.logger
|
|
2165
|
+
);
|
|
2166
|
+
}
|
|
2167
|
+
const targetBranch = response.data.base.ref;
|
|
2168
|
+
ctx.output("targetBranchName", targetBranch);
|
|
2169
|
+
ctx.output("remoteUrl", response.data.html_url);
|
|
2170
|
+
ctx.output("pullRequestNumber", pullRequestNumber);
|
|
2171
|
+
} catch (e) {
|
|
2172
|
+
throw new GithubResponseError("Pull request creation failed", e);
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
});
|
|
2176
|
+
async function requestReviewersOnPullRequest(pr, reviewers, teamReviewers, client, logger) {
|
|
2177
|
+
var _a, _b, _c, _d;
|
|
2178
|
+
try {
|
|
2179
|
+
const result = await client.rest.pulls.requestReviewers({
|
|
2180
|
+
owner: pr.owner,
|
|
2181
|
+
repo: pr.repo,
|
|
2182
|
+
pull_number: pr.number,
|
|
2183
|
+
reviewers,
|
|
2184
|
+
team_reviewers: teamReviewers
|
|
2185
|
+
});
|
|
2186
|
+
const addedUsers = (_b = (_a = result.data.requested_reviewers) == null ? void 0 : _a.join(", ")) != null ? _b : "";
|
|
2187
|
+
const addedTeams = (_d = (_c = result.data.requested_teams) == null ? void 0 : _c.join(", ")) != null ? _d : "";
|
|
2188
|
+
logger.info(
|
|
2189
|
+
`Added users [${addedUsers}] and teams [${addedTeams}] as reviewers to Pull request ${pr.number}`
|
|
2190
|
+
);
|
|
2191
|
+
} catch (e) {
|
|
2192
|
+
logger.error(
|
|
2193
|
+
`Failure when adding reviewers to Pull request ${pr.number}`,
|
|
2194
|
+
e
|
|
2195
|
+
);
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
};
|
|
2199
|
+
|
|
2200
|
+
const examples = [
|
|
2201
|
+
{
|
|
2202
|
+
description: "Initializes a git repository of contents in workspace and publish it to GitHub with default configuration.",
|
|
2203
|
+
example: yaml__default["default"].stringify({
|
|
2204
|
+
steps: [
|
|
2205
|
+
{
|
|
2206
|
+
id: "publish",
|
|
2207
|
+
action: "publish:github",
|
|
2208
|
+
name: "Publish to GitHub",
|
|
2209
|
+
input: {
|
|
2210
|
+
repoUrl: "github.com?repo=repo&owner=owner"
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
]
|
|
2214
|
+
})
|
|
2215
|
+
},
|
|
2216
|
+
{
|
|
2217
|
+
description: "Add a description.",
|
|
2218
|
+
example: yaml__default["default"].stringify({
|
|
2219
|
+
steps: [
|
|
2220
|
+
{
|
|
2221
|
+
id: "publish",
|
|
2222
|
+
action: "publish:github",
|
|
2223
|
+
name: "Publish to GitHub",
|
|
2224
|
+
input: {
|
|
2225
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
2226
|
+
description: "Initialize a git repository"
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
]
|
|
2230
|
+
})
|
|
2231
|
+
},
|
|
2232
|
+
{
|
|
2233
|
+
description: "Change visibility of the repository.",
|
|
2234
|
+
example: yaml__default["default"].stringify({
|
|
2235
|
+
steps: [
|
|
2236
|
+
{
|
|
2237
|
+
id: "publish",
|
|
2238
|
+
action: "publish:github",
|
|
2239
|
+
name: "Publish to GitHub",
|
|
2240
|
+
input: {
|
|
2241
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
2242
|
+
description: "Initialize a git repository",
|
|
2243
|
+
repoVisibility: "public"
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
]
|
|
2247
|
+
})
|
|
2248
|
+
}
|
|
2249
|
+
];
|
|
2250
|
+
|
|
2251
|
+
function createPublishGithubAction(options) {
|
|
2252
|
+
const { integrations, config, githubCredentialsProvider } = options;
|
|
2253
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
2254
|
+
id: "publish:github",
|
|
2255
|
+
description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
|
|
2256
|
+
examples,
|
|
2257
|
+
schema: {
|
|
2258
|
+
input: {
|
|
2259
|
+
type: "object",
|
|
2260
|
+
required: ["repoUrl"],
|
|
2261
|
+
properties: {
|
|
2262
|
+
repoUrl: repoUrl,
|
|
2263
|
+
description: description,
|
|
2264
|
+
homepage: homepage,
|
|
2265
|
+
access: access,
|
|
2266
|
+
bypassPullRequestAllowances: bypassPullRequestAllowances,
|
|
2267
|
+
requiredApprovingReviewCount: requiredApprovingReviewCount,
|
|
2268
|
+
restrictions: restrictions,
|
|
2269
|
+
requireCodeOwnerReviews: requireCodeOwnerReviews,
|
|
2270
|
+
dismissStaleReviews: dismissStaleReviews,
|
|
2271
|
+
requiredStatusCheckContexts: requiredStatusCheckContexts,
|
|
2272
|
+
requireBranchesToBeUpToDate: requireBranchesToBeUpToDate,
|
|
2273
|
+
requiredConversationResolution: requiredConversationResolution,
|
|
2274
|
+
repoVisibility: repoVisibility,
|
|
2275
|
+
defaultBranch: defaultBranch,
|
|
2276
|
+
protectDefaultBranch: protectDefaultBranch,
|
|
2277
|
+
protectEnforceAdmins: protectEnforceAdmins,
|
|
2278
|
+
deleteBranchOnMerge: deleteBranchOnMerge,
|
|
2279
|
+
gitCommitMessage: gitCommitMessage,
|
|
2280
|
+
gitAuthorName: gitAuthorName,
|
|
2281
|
+
gitAuthorEmail: gitAuthorEmail,
|
|
2282
|
+
allowMergeCommit: allowMergeCommit,
|
|
2283
|
+
allowSquashMerge: allowSquashMerge,
|
|
2284
|
+
squashMergeCommitTitle: squashMergeCommitTitle,
|
|
2285
|
+
squashMergeCommitMessage: squashMergeCommitMessage,
|
|
2286
|
+
allowRebaseMerge: allowRebaseMerge,
|
|
2287
|
+
allowAutoMerge: allowAutoMerge,
|
|
2288
|
+
sourcePath: sourcePath,
|
|
2289
|
+
collaborators: collaborators,
|
|
2290
|
+
hasProjects: hasProjects,
|
|
2291
|
+
hasWiki: hasWiki,
|
|
2292
|
+
hasIssues: hasIssues,
|
|
2293
|
+
token: token,
|
|
2294
|
+
topics: topics,
|
|
2295
|
+
repoVariables: repoVariables,
|
|
2296
|
+
secrets: secrets,
|
|
2297
|
+
requiredCommitSigning: requiredCommitSigning
|
|
2298
|
+
}
|
|
2299
|
+
},
|
|
2300
|
+
output: {
|
|
2301
|
+
type: "object",
|
|
2302
|
+
properties: {
|
|
2303
|
+
remoteUrl: remoteUrl,
|
|
2304
|
+
repoContentsUrl: repoContentsUrl,
|
|
2305
|
+
commitHash: commitHash
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
},
|
|
2309
|
+
async handler(ctx) {
|
|
2310
|
+
const {
|
|
2311
|
+
repoUrl,
|
|
2312
|
+
description,
|
|
2313
|
+
homepage,
|
|
2314
|
+
access,
|
|
2315
|
+
requireCodeOwnerReviews = false,
|
|
2316
|
+
dismissStaleReviews = false,
|
|
2317
|
+
bypassPullRequestAllowances,
|
|
2318
|
+
requiredApprovingReviewCount = 1,
|
|
2319
|
+
restrictions,
|
|
2320
|
+
requiredStatusCheckContexts = [],
|
|
2321
|
+
requireBranchesToBeUpToDate = true,
|
|
2322
|
+
requiredConversationResolution = false,
|
|
2323
|
+
repoVisibility = "private",
|
|
2324
|
+
defaultBranch = "master",
|
|
2325
|
+
protectDefaultBranch = true,
|
|
2326
|
+
protectEnforceAdmins = true,
|
|
2327
|
+
deleteBranchOnMerge = false,
|
|
2328
|
+
gitCommitMessage = "initial commit",
|
|
2329
|
+
gitAuthorName,
|
|
2330
|
+
gitAuthorEmail,
|
|
2331
|
+
allowMergeCommit = true,
|
|
2332
|
+
allowSquashMerge = true,
|
|
2333
|
+
squashMergeCommitTitle = "COMMIT_OR_PR_TITLE",
|
|
2334
|
+
squashMergeCommitMessage = "COMMIT_MESSAGES",
|
|
2335
|
+
allowRebaseMerge = true,
|
|
2336
|
+
allowAutoMerge = false,
|
|
2337
|
+
collaborators,
|
|
2338
|
+
hasProjects = void 0,
|
|
2339
|
+
hasWiki = void 0,
|
|
2340
|
+
hasIssues = void 0,
|
|
2341
|
+
topics,
|
|
2342
|
+
repoVariables,
|
|
2343
|
+
secrets,
|
|
2344
|
+
token: providedToken,
|
|
2345
|
+
requiredCommitSigning = false
|
|
2346
|
+
} = ctx.input;
|
|
2347
|
+
const octokitOptions = await getOctokitOptions({
|
|
2348
|
+
integrations,
|
|
2349
|
+
credentialsProvider: githubCredentialsProvider,
|
|
2350
|
+
token: providedToken,
|
|
2351
|
+
repoUrl
|
|
2352
|
+
});
|
|
2353
|
+
const client = new octokit.Octokit(octokitOptions);
|
|
2354
|
+
const { owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
2355
|
+
if (!owner) {
|
|
2356
|
+
throw new errors.InputError("Invalid repository owner provided in repoUrl");
|
|
2357
|
+
}
|
|
2358
|
+
const newRepo = await createGithubRepoWithCollaboratorsAndTopics(
|
|
2359
|
+
client,
|
|
2360
|
+
repo,
|
|
2361
|
+
owner,
|
|
2362
|
+
repoVisibility,
|
|
2363
|
+
description,
|
|
2364
|
+
homepage,
|
|
2365
|
+
deleteBranchOnMerge,
|
|
2366
|
+
allowMergeCommit,
|
|
2367
|
+
allowSquashMerge,
|
|
2368
|
+
squashMergeCommitTitle,
|
|
2369
|
+
squashMergeCommitMessage,
|
|
2370
|
+
allowRebaseMerge,
|
|
2371
|
+
allowAutoMerge,
|
|
2372
|
+
access,
|
|
2373
|
+
collaborators,
|
|
2374
|
+
hasProjects,
|
|
2375
|
+
hasWiki,
|
|
2376
|
+
hasIssues,
|
|
2377
|
+
topics,
|
|
2378
|
+
repoVariables,
|
|
2379
|
+
secrets,
|
|
2380
|
+
ctx.logger
|
|
2381
|
+
);
|
|
2382
|
+
const remoteUrl = newRepo.clone_url;
|
|
2383
|
+
const repoContentsUrl = `${newRepo.html_url}/blob/${defaultBranch}`;
|
|
2384
|
+
const commitResult = await initRepoPushAndProtect(
|
|
2385
|
+
remoteUrl,
|
|
2386
|
+
octokitOptions.auth,
|
|
2387
|
+
ctx.workspacePath,
|
|
2388
|
+
ctx.input.sourcePath,
|
|
2389
|
+
defaultBranch,
|
|
2390
|
+
protectDefaultBranch,
|
|
2391
|
+
protectEnforceAdmins,
|
|
2392
|
+
owner,
|
|
2393
|
+
client,
|
|
2394
|
+
repo,
|
|
2395
|
+
requireCodeOwnerReviews,
|
|
2396
|
+
bypassPullRequestAllowances,
|
|
2397
|
+
requiredApprovingReviewCount,
|
|
2398
|
+
restrictions,
|
|
2399
|
+
requiredStatusCheckContexts,
|
|
2400
|
+
requireBranchesToBeUpToDate,
|
|
2401
|
+
requiredConversationResolution,
|
|
2402
|
+
config,
|
|
2403
|
+
ctx.logger,
|
|
2404
|
+
gitCommitMessage,
|
|
2405
|
+
gitAuthorName,
|
|
2406
|
+
gitAuthorEmail,
|
|
2407
|
+
dismissStaleReviews,
|
|
2408
|
+
requiredCommitSigning
|
|
2409
|
+
);
|
|
2410
|
+
ctx.output("commitHash", commitResult == null ? void 0 : commitResult.commitHash);
|
|
2411
|
+
ctx.output("remoteUrl", remoteUrl);
|
|
2412
|
+
ctx.output("repoContentsUrl", repoContentsUrl);
|
|
2413
|
+
}
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
exports.createGithubActionsDispatchAction = createGithubActionsDispatchAction;
|
|
2418
|
+
exports.createGithubDeployKeyAction = createGithubDeployKeyAction;
|
|
2419
|
+
exports.createGithubEnvironmentAction = createGithubEnvironmentAction;
|
|
2420
|
+
exports.createGithubIssuesLabelAction = createGithubIssuesLabelAction;
|
|
2421
|
+
exports.createGithubRepoCreateAction = createGithubRepoCreateAction;
|
|
2422
|
+
exports.createGithubRepoPushAction = createGithubRepoPushAction;
|
|
2423
|
+
exports.createGithubWebhookAction = createGithubWebhookAction;
|
|
2424
|
+
exports.createPublishGithubAction = createPublishGithubAction;
|
|
2425
|
+
exports.createPublishGithubPullRequestAction = createPublishGithubPullRequestAction;
|
|
2426
|
+
//# sourceMappingURL=index.cjs.js.map
|