You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-69Lines changed: 26 additions & 69 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,90 +15,47 @@ _Write your own GitHub JavaScript Action and automate customized tasks unique to
15
15
</header>
16
16
17
17
<!--
18
-
<<< Author notes: Step 1 >>>
19
-
Choose 3-5 steps for your course.
20
-
The first step is always the hardest, so pick something easy!
21
-
Link to docs.github.com for further explanations.
22
-
Encourage users to open new tabs for steps!
18
+
<<< Author notes: Step 2 >>>
19
+
Start this step by acknowledging the previous step.
20
+
Define terms and link to docs.github.com.
23
21
-->
24
22
25
-
## Step 1: Initialize a new JavaScript project
23
+
## Step 2: Configure Your Action
26
24
27
-
_Welcome to the course :tada:_
25
+
_Let's keep going! :bike:_
28
26
29
-
### Configuring a workflow
27
+
### Excellent!
30
28
31
-
Actions are enabled on your repository by default, but we still have to tell our repository to use them. We do this by creating a workflow file in our repository.
29
+
Now that we have the custom action pre-requisites, let us create **joke-action** action.
32
30
33
-
A **workflow** file can be thought of as the recipe for automating a task. They house the start to finish instructions, in the form of `jobs` and `steps`, for what should happen based on specific triggers.
31
+
### :keyboard: Activity 1: Configure Your Action
34
32
35
-
Your repository can contain multiple **workflow** files that carry out a wide variety of tasks. It is important to consider this when deciding on a name for your **workflow**. The name you choose should reflect the tasks being performed.
33
+
All of the following steps take place inside of the `.github/actions/joke-action` directory.
36
34
37
-
_In our case, we will use this one **workflow**file for many things, which leads us to break this convention for teaching purposes._
35
+
We will start with using the parameters that are **required**and later implement some optional parameters as our action evolves.
38
36
39
-
Read more about [workflows](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/configuring-a-workflow#choosing-the-type-of-actions-for-your-workflow)
37
+
1. Create a new file in: `.github/actions/joke-action/action.yml`
38
+
2. Add the following contents to the `.github/actions/joke-action/action.yml` file:
40
39
41
-
## On to your development environment
40
+
```yaml
41
+
name: "my joke action"
42
42
43
-
Our JavaScript actions are going to leverage the [GitHub ToolKit](https://github.com/actions/toolkit) for developing GitHub Actions.
43
+
description: "use an external API to retrieve and display a joke"
44
44
45
-
This is an external library that we will install using `npm` which means that you will need [Node.js](https://nodejs.org/) installed.
46
-
47
-
We find writing actions to be easier from a local environment vs trying to do everything right here in the repository. Doing these steps locally allows you to use the editor of your choice so that you have all the extensions and snippets you are used to when writing code.
48
-
49
-
If you do not have a preferred environment then we suggest following along exactly as you see on the screen, which means you'll need to install [Visual Studio Code](https://code.visualstudio.com/).
50
-
51
-
## Don't forget to set up your workstation
52
-
53
-
Most of your work going forward will take place away from your Skills repository, so before continuing with the course ensure you have the following installed on your **local machine**.
54
-
55
-
1.[ ][Node.js](https://nodejs.org)
56
-
2.[ ][Visual Studio Code](https://code.visualstudio.com/) or your editor of choice
57
-
3.[ ][Git](https://git-scm.com/)
58
-
59
-
### :keyboard: Activity 1: Initialize a new JavaScript project
60
-
61
-
Once you have the necessary tools installed locally, follow these steps to begin creating your first action.
62
-
63
-
1. Open the **Terminal** (Mac and Linux) or **Command Prompt** (Windows) on your local machine
64
-
2. Clone your Skills repo to your local machine:
65
-
```shell
66
-
git clone <this repository URL>.git
67
-
```
68
-
3. Navigate to the folder you just cloned:
69
-
```shell
70
-
cd<local folder with cloned repo>
45
+
runs:
46
+
using: "node16"
47
+
main: "main.js"
71
48
```
72
-
4. We are using branch called `main`.
73
-
```shell
74
-
git switch main
75
-
```
76
-
5. Create a new folder for our actions files:
77
-
```shell
78
-
mkdir -p .github/actions/joke-action
79
-
```
80
-
6. Navigate to the `joke-action` folder you just created:
81
-
```shell
82
-
cd .github/actions/joke-action
83
-
```
84
-
7. Initialize a new project:
85
-
```shell
86
-
npm init -y
87
-
```
88
-
8. Install the **request**, **request-promise** and **@actions/core** dependencies using `npm` from the [GitHub ToolKit](https://github.com/actions/toolkit):
9. Commit those newly added files,we will remove the need to upload **node_modules** in a later step:
49
+
50
+
3. Save the `action.yml` file
51
+
4. Commit the changes and push them to the `main` branch:
93
52
```shell
94
-
git add .
95
-
git commit -m 'add project dependencies'
53
+
git add action.yml
54
+
git commit -m 'create action.yml'
55
+
git pull
56
+
git push
96
57
```
97
-
10. Push your changes to your repository:
98
-
```shell
99
-
git push
100
-
```
101
-
11. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.
58
+
5. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.
0 commit comments