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

Commit ca36621

Browse files
authored
Merge pull request #10 from githubtraining/prep-for-publish
Prep the course
2 parents 8a9fe51 + e29425a commit ca36621

File tree

9 files changed

+540
-91
lines changed

9 files changed

+540
-91
lines changed

LICENSE

Lines changed: 395 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
1-
# GitHub Actions: Writing Javascript Actions
2-
Learn how to write your own GitHub JavaScript Action! This course will empower you to begin automating customized tasks unique to your workflow.
1+
<p align="center"><a href="https://lab.github.com/"><img alt="Learning Lab bot" src="https://user-images.githubusercontent.com/16547949/62085817-83232580-b22a-11e9-8693-7c54205b04e5.png"></a></p>
2+
3+
<h1 align="center">Course: GitHub Actions: Writing JavaScript actions</h1>
4+
5+
This repository powers the Learning Lab course [_GitHub Actions: Writing JavaScript actions_](https://lab.github.com/githubtraining/github-actions:-writing-javascript-actions/).
6+
7+
Every Learning Lab course is made up of:
8+
- a [course repository](https://github.com/githubtraining/write-javascript-actions), and
9+
- a [template repository](https://github.com/githubtraining/write-javascript-actions-template)
10+
11+
The course repository is written in YAML and Markdown. The template repository could be written in any language that supports the learning objectives.
12+
13+
For more information on the goals of this course, check out the [`course-details.md`](course-details.md).
14+
15+
## Contribute
16+
17+
See something we could improve? Check out the contributing guide in the [community contributors repository](https://github.com/githubtraining/community-contributors/blob/master/CONTRIBUTING.md) for more information on the types of contributions we :heart: and instructions.
18+
19+
We :heart: our community and take great care to ensure it is fun, safe and rewarding. Please review our [Code of Conduct](https://github.com/githubtraining/community-contributors/blob/master/CODE_OF_CONDUCT.md) for community expectations and guidelines for reporting concerns.
20+
21+
## License
22+
23+
All Learning Lab course repositories are licensed under [CC-BY-4.0](../LICENSE) (c) 2019 GitHub, Inc. The template repositories associated with each course may have different licenses.
24+
25+
When using the GitHub logos, be sure to follow the [GitHub logo guidelines](https://github.com/logos)

config.yml

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
title: "GitHub Actions: Writing JavaScript Actions"
2-
tagline: Create custom automation tasks for your unique workflow using GitHub Actions
32
description: >-
43
Learn how to write your own GitHub JavaScript Action! This course will
54
empower you to begin automating customized tasks unique to your workflow.
65
template:
76
repo: "writing-javascript-actions-template"
87
name: "writing-javascript-actions"
8+
9+
# Repo artifacts:
10+
# 1. (Issue) Start here!
11+
# 2. (PR) Create my-workflow.yml
12+
# 3. (Issue) Your first JavaScript action
13+
# 4. (PR) Hello Action
14+
# 5. (Issue) Knock Knock...
15+
# 6. (PR) External APIs
16+
# 7. (Issue) Consuming Action Outputs
17+
# 8. (PR) Use Outputs
18+
# 9. (Issue) Last minute notes
19+
920
before:
1021
- type: updateBranchProtection
1122
- type: createLabel
@@ -19,11 +30,7 @@ before:
1930
color: 3F8A99
2031
- type: createIssue
2132
title: Start here!
22-
body: 01_welcome-issue.md
23-
action_id: welcomeIssue
24-
- type: respond
25-
issue: "%actions.welcomeIssue.data.number%"
26-
with: 01_welcome-activity.md
33+
body: 01_welcome-activity.md
2734
data:
2835
quicklink: "%payload.repository.html_url%/new/master?filename=.github/workflows/my-workflow.yml&workflow_template=blank"
2936
actionsUrl: "%payload.repository.html_url%/actions/new"
@@ -95,8 +102,8 @@ steps:
95102
data:
96103
workflowFile: "%payload.repository.html_url%/edit/%actions.iwPr.data.head.ref%/.github/workflows/my-workflow.yml"
97104

98-
- title: Add an Action reference
99-
description: Add an Action reference to the workflow file
105+
- title: Prep the workflow
106+
description: Prepare the workflow for your future action
100107
event: pull_request.synchronize
101108
link: "{{ repoUrl }}/pull/2"
102109
actions:
@@ -108,9 +115,10 @@ steps:
108115
data:
109116
workflowFile: "%payload.repository.html_url%/edit/%actions.workflowPr.data.head.ref%/.github/workflows/my-workflow.yml"
110117

111-
- title: On to your development environment
112-
description: Lets prepare your environemtn to start writing Actions
118+
- title: Add an Action reference
119+
description: Add an Action reference to the workflow file
113120
event: pull_request.synchronize
121+
link: "{{ repoUrl }}/pull/2"
114122
actions:
115123
- type: createIssue
116124
title: Your first JavaScript action
@@ -124,10 +132,10 @@ steps:
124132
pullRequest: Create my-workflow.yml
125133
- type: mergePullRequest
126134

127-
- title: Creating the Action metadata
128-
description: Create an action.yml file and add necessary metatdata for our Action
135+
- title: On to your development environment
136+
description: Lets prepare your environment to start writing Actions
129137
event: push
130-
# link: "{{ repoUrl }}/issue1/1"
138+
link: "{{ repoUrl }}/issues/3"
131139
actions:
132140
- type: gate
133141
left: "%payload.ref%"
@@ -160,9 +168,10 @@ steps:
160168
with: 05_create-metadata.md
161169
issue: Hello Action
162170

163-
- title: Create the Action entrypoint
164-
description: time to start adding code to main.js
171+
- title: Creating the Action metadata
172+
description: Create an action.yml file and add necessary metatdata for our Action
165173
event: pull_request.synchronize
174+
link: "{{ repoUrl }}/pull/4"
166175
actions:
167176
- type: respond
168177
with: 06_explain-runs.md
@@ -173,9 +182,10 @@ steps:
173182
data:
174183
actionsUrl: "%payload.repository.html_url%/actions"
175184

176-
- title: Adding input parameters
177-
description: extend your action to accept input parameters
185+
- title: Create the Action entrypoint
186+
description: Add code to main.js file
178187
event: pull_request.synchronize #ideally would like the workflow completing to tigger this
188+
link: "{{ repoUrl }}/pull/4"
179189
actions:
180190
- type: respond
181191
with: 07_hello-result.md
@@ -187,8 +197,9 @@ steps:
187197
with: 07_update-files.md
188198

189199
- title: Exploring your input parameters
190-
description: view the results of adding input parameter
200+
description: View the results of adding input parameter
191201
event: pull_request.synchronize #ideally would like workflow complete to trigger this
202+
link: "{{ repoUrl }}/pull/4"
192203
actions:
193204
- type: respond
194205
with: 08_input-result.md
@@ -199,8 +210,9 @@ steps:
199210
with: 08_experiment.md
200211

201212
- title: Integrating Actions with external APIs
202-
description: Write a new Action that call an external API
213+
description: Write a new Action that calls an external API
203214
event: pull_request.closed
215+
link: "{{ repoUrl }}/pull/4"
204216
actions:
205217
- type: updateBranchProtection
206218
- type: createIssue
@@ -225,7 +237,7 @@ steps:
225237
- title: Prevent the workflow from running
226238
description: Comment out the lines in the workflow to prevent unwanted runs
227239
event: pull_request
228-
# link: "{{ repoUrl }}/issue1/1"
240+
link: "{{ repoUrl }}/issues/5"
229241
actions:
230242
- type: gate
231243
gates:
@@ -257,6 +269,7 @@ steps:
257269
- title: Create your new Action metadata
258270
description: Add action.yml file for new joke action
259271
event: pull_request.synchronize
272+
link: "{{ repoUrl }}/pull/6"
260273
actions:
261274
- type: gate
262275
left: "%payload.pull_request.title%"
@@ -268,6 +281,7 @@ steps:
268281
- title: Create your Actions JavaScript files
269282
description: Add joke.j and main.js to your Action
270283
event: pull_request.synchronize
284+
link: "{{ repoUrl }}/pull/6"
271285
actions:
272286
- type: gate
273287
left: "%payload.pull_request.title%"
@@ -279,6 +293,7 @@ steps:
279293
- title: Use the joke Action in a workflow
280294
description: Edit the workflow file to now use the newly created joke Action
281295
event: pull_request.synchronize
296+
link: "{{ repoUrl }}/pull/6"
282297
actions:
283298
- type: gate
284299
left: "%payload.pull_request.title%"
@@ -296,7 +311,7 @@ steps:
296311
- title: Having Actions tell a joke... or two
297312
description: Wait for your Action to present you with a joke
298313
event: pull_request.synchronize
299-
# link: "{{ repoUrl }}/pull/2"
314+
link: "{{ repoUrl }}/pull/6"
300315
actions:
301316
- type: removeBranchProtection
302317
- type: respond
@@ -308,6 +323,7 @@ steps:
308323
- title: Configure the workflow for a third Action
309324
description: Edit the workflow to accomodate the third action
310325
event: pull_request.closed
326+
link: "{{ repoUrl }}/pull/6"
311327
actions:
312328
- type: updateBranchProtection
313329
- type: createIssue
@@ -326,7 +342,7 @@ steps:
326342
- title: Write the final Action
327343
description: Create an Action that consumes output from another Action and uses Octokit
328344
event: pull_request
329-
# link: "{{ repoUrl }}/issue1/1"
345+
link: "{{ repoUrl }}/issues/7"
330346
actions:
331347
- type: gate
332348
gates:
@@ -358,7 +374,7 @@ steps:
358374
- title: Add third Actions metadata
359375
description: Create the metadata for the third Action
360376
event: pull_request.synchronize
361-
# link: "{{ repoUrl }}/pull/2"
377+
link: "{{ repoUrl }}/pull/8"
362378
actions:
363379
- type: gate
364380
left: "%payload.pull_request.title%"
@@ -370,7 +386,7 @@ steps:
370386
- title: Add third Actions JavaScript files
371387
description: Create the JavaScript files for the third Action
372388
event: pull_request.synchronize
373-
# link: "{{ repoUrl }}/pull/2"
389+
link: "{{ repoUrl }}/pull/8"
374390
actions:
375391
- type: gate
376392
left: "%payload.pull_request.title%"
@@ -384,7 +400,7 @@ steps:
384400
- title: Trigger the third Action
385401
description: Add a pull request label to trigger the workflow
386402
event: pull_request.synchronize
387-
# link: "{{ repoUrl }}/pull/2"
403+
link: "{{ repoUrl }}/pull/8"
388404
actions:
389405
- type: gate
390406
left: "%payload.pull_request.title%"
@@ -399,16 +415,21 @@ steps:
399415
- title: Wrapping things up
400416
description: Final notes before you go
401417
event: pull_request.closed
418+
link: "{{ repoUrl }}/pull/8"
402419
actions:
403420
- type: createIssue
404421
title: Last minute notes
405422
body: great-job.md
423+
comments:
424+
- 16_using-ncc.md
425+
- 16_publishing.md
426+
- 16_complete.md
427+
action_id: finalIssue
406428
- type: respond
407-
issue: Last minute notes
408-
with: 16_using-ncc.md
409-
- type: respond
410-
issue: Last minute notes
411-
with: 16_publishing.md
412-
- type: respond
413-
issue: Last minute notes
414-
with: 16_complete.md
429+
with: go-to-final.md
430+
data:
431+
url: '%actions.finalIssue.data.html_url%'
432+
433+
tags: [
434+
"JavaScript", "API", "Actions toolkit", "GitHub Secrets", "Workflows"
435+
]

course-details.md

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,46 @@
11
[GitHub Actions](https://github.com/features/actions) is a powerful platform that empowers your team to go from code to cloud all from the comfort of your own repositories.
22

3-
Over the duration of this course, approximately 1 hour, you will learn the skills needed to begin using and customizing GitHub Actions in your unique workflow scenarios.
3+
Over the duration of this course, approximately 1 hour, you will learn the skills needed to begin using and customizing GitHub Actions to fit your unique workflow scenarios.
44

5-
**Prerequisites**
5+
## What you'll learn
66

7-
We will be using Node.js to build our action and GitHub to consume our action. This presents us with a hybrid environment, the Node.js runtime environment and the virtual machine used by GitHub Actions, that you may not be used to if you've taken other Learning Lab courses.
7+
In this course you will learn how to:
88

9-
Before we can get started there are a few things you need to setup on your **local machine**
9+
- Consume actions within a workflow file
10+
- Create custom JavaScript based actions
11+
- Publish your newly created action to the marketplace
1012

11-
1. Install [Node.js](https://nodejs.org/en/) for your operating system.
12-
2. Ensure you have a text editor installed. I'll be using Visual Studio Code, and although you are free to use your editor of choice you should be aware that using a different editor will result in your screen not matching my examples. Here are some editor options for you:
13-
1. [Visual Studio Code](https://code.visualstudio.com/) **(recommended)**
14-
2. [Atom](https://atom.io/)
15-
3. [Sublime Text](https://www.sublimetext.com/)
16-
3. Lastly, you're going to need a local installation of [Git](https://git-scm.com/) so that you can interact with this repository as you write code.
13+
You'll know the answers to questions like:
14+
15+
- What is a workflow?
16+
- What are actions?
17+
- What is action metadata?
18+
- What are GitHub Actions capable of?
19+
20+
## What you'll build
21+
22+
![screenshot of a pull request in the course with instructions on how to fetch a joke from the API, a second screenshot of a workflow running and outputting the joke: "Guy told me today he did not know what cloning is. I told him, that makes 2 of us."](https://user-images.githubusercontent.com/16547949/76105870-cce3a380-5fa3-11ea-8882-7138319b4100.png)
23+
24+
In this course you will build three actions that each accomplish different tasks designed to demonstrate the flexibility of creating and consuming JavaScript Based Actions.
25+
26+
First, you will start with the traditional "Hello World!" program which will teach you where to find the output of a workflow run. You will then modify this "Hello World!" action to accept `input` parameters which allow the action to be more dynamic.
27+
28+
Second, you will write an action that call upon an external API to retrieve a fact about cats and prints it to the workflows output. You will then modify this cat fact action to set the retrieved data as `output` for another action in the workflow to consume.
29+
30+
Lastly, you will write a third action that will open an issue in your repository making the cat fact available to everyone. You will learn how to use the `output` of previous actions as `input` for current actions in this step.
31+
32+
## Prerequisites
33+
34+
We first recommend taking the following courses:
35+
- [Hello, GitHub Actions!](https://lab.github.com/github/hello-github-actions!) to learn the basics of how GitHub Actions work
36+
- [GitHub Actions: Continuous Integration](https://lab.github.com/githubtraining/github-actions:-continuous-integration) to dive deeper into a workflow file
37+
38+
## Projects used
39+
40+
This makes use of the following open source projects. Consider exploring these repos and maybe even making contributions!
41+
42+
- [GitHub Actions Toolkit](https://github.com/actions/toolkit), a multipurpose JavaScript library for writing actions
43+
44+
## Audience
45+
46+
Developers, DevOps Engineers, students, teams

responses/01_welcome-issue.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

responses/02_modify-workflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Currently `my-workflow.yml` is not set up correctly for our use-case. It worked
55
### :keyboard: Activity: Modify my-workflow.yml to remove boilerplate steps
66

77
1. [Edit]({{workflowFile}}) the `my-workflow.yml`.
8-
2. Change the `name:` property located on `line 1` of `my-workflow.yml` to `JS Actions`
8+
2. Change the `name:` property located of `my-workflow.yml` to `JS Actions`
99
3. Rename the job from `build` to `action`
1010
4. Remove the two steps that run commands, but leave the step that runs the checkout action.
1111
5. Commit these file changes to this branch

0 commit comments

Comments
 (0)