Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Commit 649ed69

Browse files
committed
add content to 14_js-files-activity
1 parent 49d8bce commit 649ed69

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

responses/14_js-files-activity.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
### :keyboard: Activity: Create the final JavaScript file
2+
3+
I'm counting on you this time! In the previous steps I have guided you heavily on what to type along the way. This time I ask that you look back on the things you've done in this course and pull from the knowledge you already have to accomplish these tasks.
4+
5+
1. Create a file named `index.js`
6+
2. Create the `core` and `github` variables
7+
3. Create an asynchronous function named `run()`
8+
4. Inside a try/catch block define the `issueTitle`, `jokeBody`, `token` and `octokit` variables
9+
5. Use the `issues.create()` octokit method to define your API request
10+
6. Add the catch portion of the try/catch block
11+
7. Use the `setFailed()` method from the `@actions/core` package to stop your Action and log and error if something goes wrong
12+
8. Save the file
13+
9. Commit and push the changes to this branch
14+
15+
I'll respond once you complete these steps, good luck 👍
16+
17+
---
18+
19+
<details><summary>View the complete file</summary>
20+
21+
```javascript
22+
const core = require("@actions/core");
23+
const github = require("@actions/github");
24+
25+
async function run() {
26+
try {
27+
const issueTitle = core.getInput("issue-title");
28+
const jokeBody = core.getInput("joke");
29+
const token = core.getInput("repo-token");
30+
31+
const octokit = new github.GitHub(token);
32+
33+
const newIssue = await octokit.issues.create({
34+
repo: github.context.repo.repo,
35+
owner: github.context.repo.owner,
36+
title: issueTitle,
37+
body: jokeBody
38+
});
39+
} catch (error) {
40+
core.setFailed(error.message);
41+
}
42+
}
43+
44+
run();
45+
```
46+
47+
</details>

0 commit comments

Comments
 (0)