Skip to content

Commit b11bde8

Browse files
Adding Star Repo action
1 parent 8da6f63 commit b11bde8

File tree

4 files changed

+58
-11
lines changed

4 files changed

+58
-11
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import github from "../../github.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "star-repo",
6+
name: "Star Repo",
7+
description: "Star a repository. [See the docs](https://docs.github.com/en/rest/activity/starring?apiVersion=2022-11-28#star-a-repository-for-the-authenticated-user) for more info.",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
github,
12+
repoFullname: {
13+
propDefinition: [
14+
github,
15+
"repoFullname",
16+
],
17+
},
18+
},
19+
async run({ $ }) {
20+
const { repoFullname } = this;
21+
22+
// Verify repo exists
23+
let repo;
24+
try {
25+
repo = await this.github.getRepo({
26+
repoFullname,
27+
});
28+
} catch (err) {
29+
throw new ConfigurationError(`Couldn't find the **${repoFullname}** repo. Please verify the name (\`owner/repo\` format) and try again.`);
30+
}
31+
32+
// Star the repo
33+
await this.github.starRepo({
34+
repoFullname,
35+
});
36+
37+
$.export("$summary", `Successfully starred [${repo.full_name}](${repo.html_url})`);
38+
return repo.html_url;
39+
},
40+
};

components/github/github.app.mjs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default {
1515
propDefinitions: {
1616
orgName: {
1717
label: "Organization",
18-
description: "The name of the Github organization. The name is not case sensitive.",
18+
description: "The name of the Github organization (not case sensitive).",
1919
type: "string",
2020
async options() {
2121
const organizations = await this.getOrganizations();
@@ -25,7 +25,7 @@ export default {
2525
},
2626
repoFullname: {
2727
label: "Repository",
28-
description: "The name of the repository. The name is not case sensitive",
28+
description: "The name of the repository (not case sensitive). The format should be `owner/repo` (for example, `PipedreamHQ/pipedream`).",
2929
type: "string",
3030
async options({ org }) {
3131
const repositories = await this.getRepos({
@@ -888,6 +888,15 @@ export default {
888888
per_page: 100,
889889
});
890890

891+
return response.data;
892+
},
893+
async starRepo({
894+
repoFullname, ...args
895+
}) {
896+
const response = await this._client().request(`PUT /user/starred/${repoFullname}`, {
897+
...args,
898+
});
899+
891900
return response.data;
892901
},
893902
},

components/github/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/github",
3-
"version": "1.6.0",
3+
"version": "1.6.1",
44
"description": "Pipedream Github Components",
55
"main": "github.app.mjs",
66
"keywords": [

pnpm-lock.yaml

Lines changed: 6 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)