Skip to content

Commit 68c8af5

Browse files
fix: update code examples to use ES6 module syntax as required by actions/core v3.0.0 (#67)
* refactor: update joke fetching logic to use ES6 module syntax (#66) * refactor: update joke fetching logic to use ES6 module syntax * style: format code snippets for consistency in Step 2 document * fix: indent code examples in step 2 * Extra indent * Modify step 1 command to create a module * Review indentation fixes --------- Co-authored-by: skravops <skravco92@hotmail.com>
1 parent fd2a473 commit 68c8af5

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

.github/steps/1-step.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Now that your Codespace is ready, let's initialize a new Node.js project and ins
4848
1. Within your GitHub Codespace terminal window initialize a new project:
4949

5050
```sh
51-
npm init -y
51+
npm init -y && npm pkg set type=module
5252
```
5353

5454
1. Install the required dependencies:

.github/steps/2-step.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ Nice! Now that we have the project initialized and dependencies installed, it's
77
The `@actions/core` library is the main library from the [GitHub Actions Toolkit](https://github.com/actions/toolkit), a collection of packages for building JavaScript GitHub Actions. It provides essential methods to interact with the GitHub Actions runtime environment, accept action inputs, and produce outputs for other workflow steps.
88

99
> [!TIP]
10-
> The [GitHub Actions Toolkit](https://github.com/actions/toolkit) includes other useful libraries like `@actions/github` for interacting with the GitHub API and `@actions/artifact` for uploading and downloading artifacts.
11-
>
10+
> The [GitHub Actions Toolkit](https://github.com/actions/toolkit) includes other useful libraries like `@actions/github` for interacting with the GitHub API and `@actions/artifact` for uploading and downloading artifacts.
11+
>
1212
> Visit the [actions/toolkit](https://github.com/actions/toolkit) repository for more.
1313
14-
1514
### ⌨️ Activity: Implement the Dad Jokes Action
1615

1716
Let's create the source files and implement the logic for your action.
@@ -21,7 +20,7 @@ Let's create the source files and implement the logic for your action.
2120
1. Create `src/joke.js` file to hold the logic for fetching a joke from the `icanhazdadjoke.com` API:
2221

2322
```js
24-
const request = require("request-promise");
23+
import request from "request-promise";
2524

2625
const options = {
2726
method: "GET",
@@ -38,7 +37,7 @@ Let's create the source files and implement the logic for your action.
3837
return res.joke;
3938
}
4039

41-
module.exports = getJoke;
40+
export default getJoke;
4241
```
4342

4443
The `getJoke` function makes an HTTP GET request to the `icanhazdadjoke.com` API and returns a random dad joke.
@@ -48,8 +47,8 @@ Let's create the source files and implement the logic for your action.
4847
1. Create `src/main.js` that will be the main entry point for your action:
4948

5049
```js
51-
const getJoke = require("./joke");
52-
const core = require("@actions/core");
50+
import getJoke from "./joke.js";
51+
import * as core from "@actions/core";
5352

5453
async function run() {
5554
const joke = await getJoke();

0 commit comments

Comments
 (0)