Skip to content

Commit d4c413b

Browse files
GitHub app actions improvements (#14058)
* Create Issue adjustments + get push permission + improvements * Create Issue + async props * Get Repository improvements * Search issues/prs improvements * "Create or Update file contents" improvements * Get Repository Contents adjustments * Create Branch text adjustments * Text updates * Adding pagination to issues * Update Issue adjustments * Get Reviewers + adjustments * List Gists and Update Gist updates * Create Pull Request improvements * Version bumps * Version bumps * Update components/github/actions/create-branch/create-branch.mjs * Fix typos * Fixing 'create or update file contents' branch prop * Filtering out PRs from issueNumber prop * Adjusting branch on 'Get Repository Content' * Changing default review states to all * Fixing 'list gists for user' * Fix * Improve reviewStates prop description * Fixing syntax error in 'create or update file contents' * Adjusting branch name syntax * Fix: including branch when fetching file SHA * Version bump * Version bumps --------- Co-authored-by: Leo Vu <[email protected]>
1 parent d6d5192 commit d4c413b

File tree

55 files changed

+381
-314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+381
-314
lines changed

components/easy_peasy_ai/easy_peasy_ai.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
export default {
2+
assignees: {
3+
label: "Assignees",
4+
description: "One or more Users to assign to this issue",
5+
type: "string[]",
6+
optional: true,
7+
options: async () => {
8+
const collaborators = await this.github.getRepositoryCollaborators({
9+
repoFullname: this.repoFullname,
10+
});
11+
12+
return collaborators.map(({ login }) => login);
13+
},
14+
},
15+
labels: {
16+
label: "Labels",
17+
description: "The label(s) to add to the issue",
18+
type: "string[]",
19+
optional: true,
20+
options: async () => {
21+
const labels = await this.github.getRepositoryLabels({
22+
repoFullname: this.repoFullname,
23+
});
24+
25+
return labels.map(({ name }) => name);
26+
},
27+
},
28+
milestoneNumber: {
29+
type: "integer",
30+
label: "Milestone Number",
31+
description: "The number of a milestone to associate the issue with",
32+
optional: true,
33+
options: async () => {
34+
const items = await this.github.getRepositoryMilestones({
35+
repoFullname: this.repoFullname,
36+
});
37+
38+
return items.map((item) => ({
39+
label: item.title,
40+
value: +item.number,
41+
}));
42+
},
43+
},
44+
pullNumber: {
45+
type: "integer",
46+
label: "Pull Request Number",
47+
description: "The pull request to get reviewers for",
48+
options: async ({ page }) => {
49+
const prs = await this.github.getRepositoryPullRequests({
50+
page: page + 1,
51+
repoFullname: this.repoFullname,
52+
});
53+
54+
return prs.map((pr) => ({
55+
label: pr.title,
56+
value: +pr.number,
57+
}));
58+
},
59+
},
60+
};

components/github/actions/create-branch/create-branch.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import github from "../../github.app.mjs";
44
export default {
55
key: "github-create-branch",
66
name: "Create Branch",
7-
description: "Create a new branch in a Github repo. [See docs here](https://docs.github.com/en/rest/git/refs?apiVersion=2022-11-28#create-a-reference)",
8-
version: "0.0.12",
7+
description: "Create a new branch in a Github repo. [See the documentation](https://docs.github.com/en/rest/git/refs?apiVersion=2022-11-28#create-a-reference)",
8+
version: "0.0.13",
99
type: "action",
1010
props: {
1111
github,
@@ -17,12 +17,12 @@ export default {
1717
},
1818
branchName: {
1919
label: "Branch Name",
20-
description: "The name of the new branch that will be crated",
20+
description: "The name of the new branch that will be created",
2121
type: "string",
2222
},
2323
branchSha: {
2424
label: "Source Branch",
25-
description: "The source branch that will be used to create the new branch",
25+
description: "The source branch that will be used to create the new branch. Defaults to the repository's default branch (usually `main` or `master`)",
2626
propDefinition: [
2727
github,
2828
"branch",

components/github/actions/create-gist/create-gist.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import utils from "../../actions/common/utils.mjs";
44
export default {
55
key: "github-create-gist",
66
name: "Create Gist",
7-
description: "Allows you to add a new gist with one or more files. [See docs here](https://docs.github.com/en/rest/gists/gists?apiVersion=2022-11-28#create-a-gist)",
8-
version: "0.0.6",
7+
description: "Allows you to add a new gist with one or more files. [See the documentation](https://docs.github.com/en/rest/gists/gists?apiVersion=2022-11-28#create-a-gist)",
8+
version: "0.0.7",
99
type: "action",
1010
props: {
1111
github,

components/github/actions/create-issue-comment/create-issue-comment.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import github from "../../github.app.mjs";
33
export default {
44
key: "github-create-issue-comment",
55
name: "Create Issue Comment",
6-
description: "Create a new comment in a issue. [See docs here](https://docs.github.com/en/rest/issues/comments#create-an-issue-comment)",
7-
version: "0.0.17",
6+
description: "Create a new comment in a issue. [See the documentation](https://docs.github.com/en/rest/issues/comments#create-an-issue-comment)",
7+
version: "0.0.18",
88
type: "action",
99
props: {
1010
github,

components/github/actions/create-issue/create-issue.mjs

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import { checkPushPermission } from "../../common/utils.mjs";
12
import github from "../../github.app.mjs";
3+
import asyncProps from "../common/asyncProps.mjs";
24

35
export default {
46
key: "github-create-issue",
57
name: "Create Issue",
6-
description: "Create a new issue in a Gihub repo. [See docs here](https://docs.github.com/en/rest/issues/issues#create-an-issue)",
7-
version: "0.2.16",
8+
description: "Create a new issue in a Gihub repo. [See the documentation](https://docs.github.com/en/rest/issues/issues#create-an-issue)",
9+
version: "0.3.0",
810
type: "action",
911
props: {
1012
github,
@@ -13,6 +15,7 @@ export default {
1315
github,
1416
"repoFullname",
1517
],
18+
reloadProps: true,
1619
},
1720
title: {
1821
label: "Title",
@@ -21,47 +24,41 @@ export default {
2124
},
2225
body: {
2326
label: "Body",
24-
description: "The contents of the issue",
27+
description: "The text body of the issue",
2528
type: "string",
2629
optional: true,
2730
},
28-
labels: {
29-
label: "Labels",
30-
description: "Labels to associate with this issue. NOTE: Only users with push access can set labels for new issues",
31-
optional: true,
32-
propDefinition: [
33-
github,
34-
"labels",
35-
(c) => ({
36-
repoFullname: c.repoFullname,
37-
}),
38-
],
39-
},
40-
assignees: {
41-
label: "Assignees",
42-
description: "Logins for Users to assign to this issue. NOTE: Only users with push access can set assignees for new issues",
43-
optional: true,
44-
propDefinition: [
45-
github,
46-
"collaborators",
47-
(c) => ({
48-
repoFullname: c.repoFullname,
49-
}),
50-
],
51-
},
31+
},
32+
methods: {
33+
checkPushPermission,
34+
},
35+
async additionalProps() {
36+
const canPush = await this.checkPushPermission();
37+
return canPush
38+
? {
39+
assignees: asyncProps.assignees,
40+
labels: asyncProps.labels,
41+
milestoneNumber: asyncProps.milestoneNumber,
42+
}
43+
: {
44+
infoBox: {
45+
type: "alert",
46+
alertType: "info",
47+
content: "Labels, assignees and milestones can only be set by users with push access to the repository.",
48+
},
49+
};
5250
},
5351
async run({ $ }) {
54-
const response = await this.github.createIssue({
55-
repoFullname: this.repoFullname,
56-
data: {
57-
title: this.title,
58-
body: this.body,
59-
labels: this.labels,
60-
assignees: this.assignees,
61-
},
52+
const { // eslint-disable-next-line no-unused-vars
53+
github, repoFullname, infoBox, ...data
54+
} = this;
55+
56+
const response = await github.createIssue({
57+
repoFullname,
58+
data,
6259
});
6360

64-
$.export("$summary", "Successfully created issue.");
61+
$.export("$summary", `Successfully created issue (ID: ${response.id})`);
6562

6663
return response;
6764
},

components/github/actions/create-or-update-file-contents/create-or-update-file-contents.mjs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import github from "../../github.app.mjs";
22

33
export default {
44
key: "github-create-or-update-file-contents",
5-
name: "Create or update file contents",
6-
description: "Create or update a file in a repository. This will replace an existing file. [See docs here](https://docs.github.com/en/rest/repos/contents#create-or-update-file-contents)",
7-
version: "0.0.13",
5+
name: "Create or Update File Contents",
6+
description: "Create or update a file in a repository. [See the documentation](https://docs.github.com/en/rest/repos/contents#create-or-update-file-contents)",
7+
version: "0.1.0",
88
type: "action",
99
props: {
1010
github,
@@ -32,21 +32,25 @@ export default {
3232
default: "Pipedream - {{steps.trigger.context.workflow_name}} ({{steps.trigger.context.workflow_id}})",
3333
},
3434
branch: {
35-
label: "Branch",
35+
propDefinition: [
36+
github,
37+
"branch",
38+
(c) => ({
39+
repoFullname: c.repoFullname,
40+
}),
41+
],
3642
description:
37-
"The branch name. Defaults to the repository’s default branch (usually `master`)",
38-
type: "string",
43+
"The branch to use. Defaults to the repository's default branch (usually `main` or `master`)",
3944
optional: true,
4045
},
4146
},
4247
async run({ $ }) {
43-
44-
const response = await this.github.createOrUpdateFileContent({
45-
repoFullname: this.repoFullname,
46-
path: this.path,
47-
commitMessage: this.commitMessage,
48-
fileContent: this.fileContent,
49-
branch: this.branch,
48+
const {
49+
github, branch, ...data
50+
} = this;
51+
const response = await github.createOrUpdateFileContent({
52+
...data,
53+
branch: branch && branch.split("/")[1],
5054
});
5155

5256
$.export("$summary", `Successfully set contents of ${this.path}${this.branch

0 commit comments

Comments
 (0)