Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
995077e
Create Issue adjustments + get push permission + improvements
GTFalcao Sep 21, 2024
ed0e29b
Create Issue + async props
GTFalcao Sep 21, 2024
2e82e77
Get Repository improvements
GTFalcao Sep 21, 2024
2cab7ff
Search issues/prs improvements
GTFalcao Sep 21, 2024
a9cb28a
"Create or Update file contents" improvements
GTFalcao Sep 22, 2024
9122939
Get Repository Contents adjustments
GTFalcao Sep 22, 2024
fa3baa6
Create Branch text adjustments
GTFalcao Sep 22, 2024
5e468d2
Text updates
GTFalcao Sep 22, 2024
cc12ab8
Adding pagination to issues
GTFalcao Sep 23, 2024
b17eeac
Update Issue adjustments
GTFalcao Sep 23, 2024
763bdeb
Get Reviewers + adjustments
GTFalcao Sep 23, 2024
225921b
List Gists and Update Gist updates
GTFalcao Sep 23, 2024
bf91b7c
Create Pull Request improvements
GTFalcao Sep 23, 2024
4163d3e
Merge branch 'master' into 13927-github-actions-improvements
GTFalcao Sep 23, 2024
2bf2abc
Version bumps
GTFalcao Sep 23, 2024
2a6786a
Version bumps
GTFalcao Sep 23, 2024
e02c8a1
Merge branch '13927-github-actions-improvements' of https://github.co…
GTFalcao Sep 23, 2024
c93226b
Update components/github/actions/create-branch/create-branch.mjs
vunguyenhung Sep 24, 2024
7a183e3
Fix typos
vunguyenhung Sep 24, 2024
84219aa
Merge branch 'master' into 13927-github-actions-improvements
GTFalcao Sep 24, 2024
53ba27e
Merge branch '13927-github-actions-improvements' of https://github.co…
GTFalcao Sep 24, 2024
195f4cb
Fixing 'create or update file contents' branch prop
GTFalcao Sep 24, 2024
72f7246
Filtering out PRs from issueNumber prop
GTFalcao Sep 25, 2024
ee80a7d
Adjusting branch on 'Get Repository Content'
GTFalcao Sep 25, 2024
6dfb780
Changing default review states to all
GTFalcao Sep 25, 2024
5ecffde
Fixing 'list gists for user'
GTFalcao Sep 25, 2024
6e41e47
Fix
GTFalcao Sep 25, 2024
e0994c9
Improve reviewStates prop description
vunguyenhung Sep 25, 2024
962d622
Fixing syntax error in 'create or update file contents'
GTFalcao Sep 25, 2024
acee736
Merge branch '13927-github-actions-improvements' of https://github.co…
GTFalcao Sep 25, 2024
abfd83d
Adjusting branch name syntax
GTFalcao Sep 26, 2024
b88c1b5
Fix: including branch when fetching file SHA
GTFalcao Sep 26, 2024
f689f33
Merge branch 'master' into 13927-github-actions-improvements
GTFalcao Sep 27, 2024
cce2b03
Version bump
GTFalcao Sep 27, 2024
c08842a
Version bumps
GTFalcao Sep 27, 2024
7971ba9
Merge branch 'master' into 13927-github-actions-improvements
GTFalcao Sep 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/easy_peasy_ai/easy_peasy_ai.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
60 changes: 60 additions & 0 deletions components/github/actions/common/asyncProps.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
export default {
assignees: {
label: "Assignees",
description: "One or more Users to assign to this issue",
type: "string[]",
optional: true,
options: async () => {
const collaborators = await this.github.getRepositoryCollaborators({
repoFullname: this.repoFullname,
});

return collaborators.map(({ login }) => login);
},
},
labels: {
label: "Labels",
description: "The label(s) to add to the issue",
type: "string[]",
optional: true,
options: async () => {
const labels = await this.github.getRepositoryLabels({
repoFullname: this.repoFullname,
});

return labels.map(({ name }) => name);
},
},
Comment on lines +15 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider refactoring common patterns in 'assignees' and 'labels' properties

The 'labels' property is structurally similar to the 'assignees' property, with the main difference being the API call and the mapped property. This similarity suggests an opportunity for refactoring to reduce code duplication.

Consider creating a higher-order function to generate these property objects. This could improve maintainability and reduce the chance of inconsistencies. Here's a potential refactor:

const createAsyncProperty = (label, description, apiCall, mapFunction) => ({
  label,
  description,
  type: "string[]",
  optional: true,
  options: async () => {
    const items = await apiCall();
    return items.map(mapFunction);
  },
});

export default {
  assignees: createAsyncProperty(
    "Assignees",
    "One or more Users to assign to this issue",
    () => this.github.getRepositoryCollaborators({ repoFullname: this.repoFullname }),
    ({ login }) => login
  ),
  labels: createAsyncProperty(
    "Labels",
    "The label(s) to add to the issue",
    () => this.github.getRepositoryLabels({ repoFullname: this.repoFullname }),
    ({ name }) => name
  ),
  // ... other properties
};

This refactoring would also make it easier to add new properties with similar structures in the future.

milestoneNumber: {
type: "integer",
label: "Milestone Number",
description: "The number of a milestone to associate the issue with",
optional: true,
options: async () => {
const items = await this.github.getRepositoryMilestones({
repoFullname: this.repoFullname,
});

return items.map((item) => ({
label: item.title,
value: +item.number,
}));
},
},
pullNumber: {
type: "integer",
label: "Pull Request Number",
description: "The pull request to get reviewers for",
options: async ({ page }) => {
const prs = await this.github.getRepositoryPullRequests({
page: page + 1,
repoFullname: this.repoFullname,
});

return prs.map((pr) => ({
label: pr.title,
value: +pr.number,
}));
},
},
};
8 changes: 4 additions & 4 deletions components/github/actions/create-branch/create-branch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import github from "../../github.app.mjs";
export default {
key: "github-create-branch",
name: "Create Branch",
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)",
version: "0.0.12",
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)",
version: "0.0.13",
type: "action",
props: {
github,
Expand All @@ -17,12 +17,12 @@ export default {
},
branchName: {
label: "Branch Name",
description: "The name of the new branch that will be crated",
description: "The name of the new branch that will be created",
type: "string",
},
branchSha: {
label: "Source Branch",
description: "The source branch that will be used to create the new branch",
description: "The source branch that will be used to create the new branch. Defaults to the repository's default branch (usually `main` or `master`)",
propDefinition: [
github,
"branch",
Expand Down
4 changes: 2 additions & 2 deletions components/github/actions/create-gist/create-gist.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import utils from "../../actions/common/utils.mjs";
export default {
key: "github-create-gist",
name: "Create Gist",
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)",
version: "0.0.6",
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)",
version: "0.0.7",
type: "action",
props: {
github,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import github from "../../github.app.mjs";
export default {
key: "github-create-issue-comment",
name: "Create Issue Comment",
description: "Create a new comment in a issue. [See docs here](https://docs.github.com/en/rest/issues/comments#create-an-issue-comment)",
version: "0.0.17",
description: "Create a new comment in a issue. [See the documentation](https://docs.github.com/en/rest/issues/comments#create-an-issue-comment)",
version: "0.0.18",
type: "action",
props: {
github,
Expand Down
69 changes: 33 additions & 36 deletions components/github/actions/create-issue/create-issue.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { checkPushPermission } from "../../common/utils.mjs";
import github from "../../github.app.mjs";
import asyncProps from "../common/asyncProps.mjs";

export default {
key: "github-create-issue",
name: "Create Issue",
description: "Create a new issue in a Gihub repo. [See docs here](https://docs.github.com/en/rest/issues/issues#create-an-issue)",
version: "0.2.16",
description: "Create a new issue in a Gihub repo. [See the documentation](https://docs.github.com/en/rest/issues/issues#create-an-issue)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in description: Correct "Gihub" to "GitHub"

There's a typo in the description property. "Gihub" should be corrected to "GitHub".

Apply this diff to fix the typo:

-description: "Create a new issue in a Gihub repo. [See the documentation](https://docs.github.com/en/rest/issues/issues#create-an-issue)",
+description: "Create a new issue in a GitHub repo. [See the documentation](https://docs.github.com/en/rest/issues/issues#create-an-issue)",
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
description: "Create a new issue in a Gihub repo. [See the documentation](https://docs.github.com/en/rest/issues/issues#create-an-issue)",
description: "Create a new issue in a GitHub repo. [See the documentation](https://docs.github.com/en/rest/issues/issues#create-an-issue)",

version: "0.3.0",
type: "action",
props: {
github,
Expand All @@ -13,6 +15,7 @@ export default {
github,
"repoFullname",
],
reloadProps: true,
},
title: {
label: "Title",
Expand All @@ -21,47 +24,41 @@ export default {
},
body: {
label: "Body",
description: "The contents of the issue",
description: "The text body of the issue",
type: "string",
optional: true,
},
labels: {
label: "Labels",
description: "Labels to associate with this issue. NOTE: Only users with push access can set labels for new issues",
optional: true,
propDefinition: [
github,
"labels",
(c) => ({
repoFullname: c.repoFullname,
}),
],
},
assignees: {
label: "Assignees",
description: "Logins for Users to assign to this issue. NOTE: Only users with push access can set assignees for new issues",
optional: true,
propDefinition: [
github,
"collaborators",
(c) => ({
repoFullname: c.repoFullname,
}),
],
},
},
methods: {
checkPushPermission,
},
async additionalProps() {
const canPush = await this.checkPushPermission();
return canPush
? {
assignees: asyncProps.assignees,
labels: asyncProps.labels,
milestoneNumber: asyncProps.milestoneNumber,
}
: {
infoBox: {
type: "alert",
alertType: "info",
content: "Labels, assignees and milestones can only be set by users with push access to the repository.",
},
};
},
async run({ $ }) {
const response = await this.github.createIssue({
repoFullname: this.repoFullname,
data: {
title: this.title,
body: this.body,
labels: this.labels,
assignees: this.assignees,
},
const { // eslint-disable-next-line no-unused-vars
github, repoFullname, infoBox, ...data
} = this;

const response = await github.createIssue({
repoFullname,
data,
});

$.export("$summary", "Successfully created issue.");
$.export("$summary", `Successfully created issue (ID: ${response.id})`);

return response;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import github from "../../github.app.mjs";

export default {
key: "github-create-or-update-file-contents",
name: "Create or update file contents",
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)",
version: "0.0.13",
name: "Create or Update File Contents",
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)",
version: "0.1.0",
type: "action",
props: {
github,
Expand Down Expand Up @@ -32,21 +32,25 @@ export default {
default: "Pipedream - {{steps.trigger.context.workflow_name}} ({{steps.trigger.context.workflow_id}})",
},
branch: {
label: "Branch",
propDefinition: [
github,
"branch",
(c) => ({
repoFullname: c.repoFullname,
}),
],
description:
"The branch name. Defaults to the repository’s default branch (usually `master`)",
type: "string",
"The branch to use. Defaults to the repository's default branch (usually `main` or `master`)",
optional: true,
},
},
async run({ $ }) {

const response = await this.github.createOrUpdateFileContent({
repoFullname: this.repoFullname,
path: this.path,
commitMessage: this.commitMessage,
fileContent: this.fileContent,
branch: this.branch,
const {
github, branch, ...data
} = this;
const response = await github.createOrUpdateFileContent({
...data,
branch: branch && branch.split("/")[1],
});

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