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

Commit 248ab69

Browse files
committed
adding more logic and responses
1 parent cd16f6c commit 248ab69

7 files changed

Lines changed: 103 additions & 24 deletions

File tree

config.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,18 @@ steps:
139139
actions:
140140
- type: respond
141141
with: 04_explain-runs.md
142+
- type: respond
143+
with: 04_main-js.md
144+
data:
145+
actionsUrl: "%payload.repository.html_url%/actions"
146+
147+
- title: Adding input parameters
148+
description: extend your action to accept input parameters
149+
event: check_suite.completed
150+
actions:
151+
- type: gate
152+
left: "%payload.check_suite.app.name%"
153+
operator: ===
154+
right: "GitHub Actions"
155+
- type: respond
156+
with: 04_add-input-params.md

responses/03_reference-actions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ If you'd like to see more examples of workflows and Actions then check out these
2525

2626
1. [Edit]({{workflowFile}}) the `my-workflow.yml`.
2727
1. Add a new `step:` and `name:` it `hello-action`
28-
1. Set the value of `uses:` to `./.github/actions/hello-world`
28+
1. Set the value of `uses:` to `.github/actions/hello-world`
2929
1. Commit these file changes to this branch
3030

3131
---
@@ -46,6 +46,6 @@ jobs:
4646
- uses: actions/checkout@v1
4747

4848
- name: hello-action
49-
uses: ./.github/actions/hello-world
49+
uses: .github/actions/hello-world
5050
```
5151
</details>

responses/04_add-input-params.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# add input parameters

responses/04_create-metadata.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ We will start with using the parameters that are **required** and later implemen
1313
1. Create a file named `action.yml`
1414
2. Use the `name` parameter to name your Action `"my hello action"`
1515
3. Next, add a `description` parameter and give it a value of `"say hello with Actions"`
16-
4. Lastly, define the `run` parameter to use `"node12"` to execute the `"main.js"` file that doesn't exist yet.
16+
4. Lastly, define the `run` parameter to use `"node12"` to execute the `"main.js"`
1717

18-
<details><summary>View the complete file</summary><img src="https://i.imgur.com/xCuBdI4.png" alt="screenshot of action.yml file" />
18+
<details><summary>View the complete file</summary><img src="https://i.imgur.com/xCuBdI4.png" alt="screenshot of action.yml file" />
1919

20-
<details><summary>Raw code to copy</summary>
20+
<details><summary>Raw code to copy</summary>
2121

22-
```yaml
23-
name: "my hello action"
22+
```yaml
23+
name: "my hello action"
2424

25-
description: "say hello with Actions"
25+
description: "say hello with Actions"
2626

27-
runs:
28-
using: "node12"
29-
main: "main.js"
30-
```
31-
</details>
27+
runs:
28+
using: "node12"
29+
main: "main.js"
30+
```
31+
</details>
3232
33-
</details>
33+
</details>
3434
3535
5. Save the `action.yml` file
3636
6. commit the changes:

responses/04_explain-metadata.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
Every GitHub Action that we write needs to be accompanied by a metadata file. This file has a few rules to it, lets outline those now:
44

55
- Filename **must** be `action.yml`
6-
- Placed in the root directory of your Action
76
- Required for both Docker container and JavaScript Actions
87
- Written in YAML syntax
98

109
This file defines the following information about your Action:
1110

12-
<details><summary>Name</summary>This parameter is <b>required</b>. The name of your action. Helps visually identify the Actions in a job.</details>
13-
<details><summary>Author</summary>This parameter is <b>optional</b>. The name of who wrote the Action.</details>
14-
<details><summary>Description</summary>This parameter is <b>required</b>. A summary of what your Action does.</details>
15-
<details><summary>Inputs</summary>This parameter is <b>optional</b>. Input parameters allow you to specify data that the action expects to use during runtime. These parameters become environment variables in the runner.</details>
16-
<details><summary>Outputs</summary>This parameter is <b>optional</b>. Specifies the data that subsequent actions can use later in the workflow after the action that defines these outputs has run.</details>
17-
<details><summary>Runs</summary>This parameter is <b>required</b>. The command to run when the Action executes.</details>
18-
<details><summary>Branding</summary>This parameter is <b>optional</b>. You can use a color and Feather icon to create a badge to personalize and distinguish your action in GitHub Marketplace.</details>
11+
12+
13+
| Parameter | Description | Required |
14+
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | :----------------: |
15+
| Name | The name of your Action. Helps visually identify the Actions in a job. | :white_check_mark: |
16+
| Description | A summary of what your Action does. | :white_check_mark: |
17+
| Inputs | Input parameters allow you to specify data that the action expects to use during runtime. These parameters become environment variables in the runner. ||
18+
| Outputs | Specifies the data that subsequent actions can use later in the workflow after the action that defines these outputs has run. ||
19+
| Runs | The command to run when the Action executes. | :white_check_mark: |
20+
| Branding | You can use a color and Feather icon to create a badge to personalize and distinguish your action in GitHub Marketplace. ||
1921

2022
---
2123

responses/04_explain-runs.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,26 @@
1-
# explain runs
1+
## Runs
2+
3+
As you have learned `runs:` defines the command necessary to execute your Action.
4+
5+
In our current case `runs:` takes 2 arguments
6+
7+
- `using:`
8+
- `main:`
9+
10+
These are specific to JavaScript Actions. It is our way of telling the runner to run the `main.js` file using `node12`
11+
12+
This is no different than running a local JavaScript file using Node like you see below:
13+
![node example](https://media.giphy.com/media/W1kCFFsaoYlsmpVtxv/giphy.gif)
14+
15+
Which means that the value of `main:` would be different if your file was not named `main.js`.
16+
![different filename example](https://media.giphy.com/media/H7CCHqH06pVbQeWmlb/giphy.gif)
17+
In this scenario our metadata block would look like this:
18+
```yaml
19+
runs:
20+
using: 'node12'
21+
main: 'bread.js'
22+
```
23+
24+
---
25+
26+
Keep this in mind because later we will be referencing a file that is not in the same directory of the `action.yml`

responses/04_main-js.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,37 @@
1-
## some main js
1+
## Time to code 💻
2+
3+
You may have noticed that your workflow has been running every time a change has been made. This is expected since it's trigger is a `push` event.
4+
5+
Hopefully you have also noticed that it fails when it reaches the `hello-action` step.
6+
7+
As we can see from the screenshot, as well as the [Actions]({{actionsUrl}}) tab, the failure occurs because the runner cannot find the Action.
8+
9+
Lets fix that by creating the Action it is looking for!
10+
11+
### :keyboard: Activity: Hello World
12+
13+
💡All of the following steps take place inside of the `.github/actions/hello-world` directory.
14+
15+
The first iteration of our Action will follow the traditional path of logging "Hello World" 👋to the console. We will expand on this as we move forward, for now it's a good test to make sure all of our files are set up correctly 😄
16+
17+
1. Create a file named `main.js`
18+
2. Log "Hello World" to the console
19+
<details><summary>View the complete file</summary><img src="https://i.imgur.com/ABXoNtE.png" alt="screenshot of main.js file" />
20+
21+
<details><summary>Raw code to copy</summary>
22+
23+
```javascript
24+
console.log("Hello World")
25+
```
26+
</details>
27+
28+
</details>
29+
3. Save the `main.js` file
30+
4. commit the changes:
31+
`git add .`
32+
`git commit -m 'create main.js'`
33+
5. push them to the `hello-world` branch:
34+
`git push`
35+
36+
---
37+
I'll respond here once the workflow has completed running. Remember, you need to **push** your changes to trigger it!

0 commit comments

Comments
 (0)