Skip to content

Commit 09412c2

Browse files
authored
pull base content,head:MicrosoftDocs:main,into:wwlpublishsync
2 parents ab06a5c + ecb2e35 commit 09412c2

22 files changed

+83
-80
lines changed

learn-pr/github/automate-github-using-github-script/1-introduction.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ uid: learn.github.automate-github-using-github-script.1-introduction
33
title: Introduction
44
metadata:
55
title: Introduction
6-
description: Learn to interact with the GitHub API from GitHub Actions using GitHub Script.
7-
ms.date: 04/13/2022
6+
description: Learn to interact with the GitHub API from GitHub Actions by using GitHub Script.
7+
ms.date: 05/19/2025
88
author: a-a-ron
99
ms.author: aastewar
1010
ms.topic: unit

learn-pr/github/automate-github-using-github-script/2-what-is-github-script.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ uid: learn.github.automate-github-using-github-script.2-what-is-github-script
33
title: What is GitHub Script?
44
metadata:
55
title: What is GitHub Script?
6-
description: Learn to interact with the GitHub API from GitHub Actions using GitHub Script.
7-
ms.date: 04/13/2022
6+
description: Learn to interact with the GitHub API from GitHub Actions by using GitHub Script.
7+
ms.date: 05/19/2025
88
author: a-a-ron
99
ms.author: aastewar
1010
ms.topic: unit

learn-pr/github/automate-github-using-github-script/3-use-github-script.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ uid: learn.github.automate-github-using-github-script.3-use-github-script
33
title: Exercise - Using GitHub Script in GitHub Actions
44
metadata:
55
title: Exercise - Using GitHub Script in GitHub Actions
6-
description: Learn to interact with the GitHub API from GitHub Actions using GitHub Script.
7-
ms.date: 04/13/2022
6+
description: Learn to interact with the GitHub API from GitHub Actions by using GitHub Script.
7+
ms.date: 05/19/2025
88
author: a-a-ron
99
ms.author: aastewar
1010
ms.topic: unit

learn-pr/github/automate-github-using-github-script/4-knowledge-check.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ uid: learn.github.automate-github-using-github-script.4-knowledge-check
33
title: Module assessment
44
metadata:
55
title: Module assessment
6-
description: Check what you've learned.
7-
ms.date: 04/13/2022
6+
description: Check what you learned.
7+
ms.date: 05/19/2025
88
author: a-a-ron
99
ms.author: aastewar
1010
ms.topic: unit
@@ -18,32 +18,32 @@ quiz:
1818
choices:
1919
- content: "A programming language that compiles to JavaScript."
2020
isCorrect: false
21-
explanation: "GitHub Script is not a programming language."
22-
- content: "An automation syntax for GitHub Shell."
21+
explanation: "GitHub Script isn't a programming language."
22+
- content: "An automation syntax for GitHub shell."
2323
isCorrect: false
24-
explanation: "GitHub Script is not a scripting language."
24+
explanation: "GitHub Script isn't a scripting language."
2525
- content: "A workflow action that enables GitHub API access from GitHub Actions."
2626
isCorrect: true
2727
explanation: "It allows you to script any API usage that is available through the octokit/rest.js library."
2828
- content: "What is the difference between GitHub Script and GitHub Actions?"
2929
choices:
3030
- content: "GitHub Actions is for automating build and release pipelines. It was written in the GitHub Script programming language."
3131
isCorrect: false
32-
explanation: "GitHub Script is not a programming language."
32+
explanation: "GitHub Script isn't a programming language."
3333
- content: "GitHub Actions is a workflow engine that automates the execution of actions. GitHub Script is one of the actions available for use in a workflow."
3434
isCorrect: true
35-
explanation: "GitHub Actions workflows may contain GitHub Script actions."
35+
explanation: "GitHub Actions workflows can contain GitHub Script actions."
3636
- content: "GitHub Actions automates workflows that run inside GitHub. GitHub Script automates workflows that run outside of GitHub."
3737
isCorrect: false
3838
explanation: "GitHub Script is a workflow action that runs inside GitHub."
3939
- content: "Why would someone use the following YAML in a GitHub Script action: `if: contains(github.event.issue.labels.*.name, 'bug')`?"
4040
choices:
41-
- content: "To ensure that the script only runs when the target issue has been labeled as a bug."
41+
- content: "To ensure that the script runs only when the target issue is labeled as a bug."
4242
isCorrect: true
43-
explanation: "This expression instructs the action to ignore issues that are not labeled as a bug."
44-
- content: "To make sure that new issue names do not violate the bug reporting policy when created."
43+
explanation: "This expression instructs the action to ignore issues that aren't labeled as bugs."
44+
- content: "To make sure that new issue names don't violate the bug reporting policy when issues are created."
4545
isCorrect: false
46-
explanation: "This snippet will not help you enforce issue creation policy."
46+
explanation: "This snippet doesn't enforce issue creation policy."
4747
- content: "To automatically flag any commits containing code matching the `github.event.issue.labels.*.name` namespace pattern as a bug."
4848
isCorrect: false
49-
explanation: "This snippet will not help you enforce code commit policy."
49+
explanation: "This snippet doesn't enforce code commit policy."

learn-pr/github/automate-github-using-github-script/5-summary.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Summary
44
metadata:
55
title: Summary
66
description: Review what you've learned.
7-
ms.date: 04/13/2022
7+
ms.date: 05/19/2025
88
author: a-a-ron
99
ms.author: aastewar
1010
ms.topic: unit

learn-pr/github/automate-github-using-github-script/includes/1-introduction.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
GitHub Script is a workflow action that provides you with access to the GitHub API from within your GitHub Actions. It offers convenient support for any API usage available in [octokit/rest.js](https://octokit.github.io/rest.js/?azure-portal=true).
1+
GitHub Script is a workflow action that provides you with access to the GitHub API from within GitHub Actions. It offers convenient support for any API usage that's available in [octokit/rest.js](https://octokit.github.io/rest.js/?azure-portal=true).
22

3-
Suppose you maintain a vibrant GitHub repository. Your project has a substantial number of consumers and contributors, and you want to make sure they have a welcoming experience. You also find that the responsibilities of managing the team's planning and workload can really add up. You need a solution that allows you to hand off some of the mundane tasks to automation so that you can focus on areas where you really add value. You know that GitHub offers an API that will let you automatically reply to new issues and begin the triage workflow for new bug reports. You just haven't invested the time in figuring it all out, until now.
3+
Suppose you maintain a vibrant GitHub repository. Your project has a substantial number of consumers and contributors, and you want to make sure they have a welcoming experience. You also find that the responsibilities of managing the team's planning and workload can really add up. You need a solution that enables you to hand off some of the mundane tasks to automation so that you can focus on areas where you really add value. You know that GitHub provides an API that lets you automatically reply to new issues and begin the triage workflow for new bug reports. You just haven't invested the time in figuring it all out, until now.
44

55
In this module, you'll learn how to interact with the GitHub API from a GitHub Actions workflow by using GitHub Script.
66

@@ -9,8 +9,8 @@ In this module, you'll learn how to interact with the GitHub API from a GitHub A
99
In this module, you'll:
1010

1111
- Use GitHub Script in your workflow.
12-
- Comment on issues using octokit.
13-
- Add issues to a project board using octokit.
12+
- Comment on issues by using Octokit.
13+
- Add issues to a project board by using Octokit.
1414
- Use the workflow expression syntax to filter when jobs run in a workflow.
1515

1616
## Prerequisites

learn-pr/github/automate-github-using-github-script/includes/2-what-is-github-script.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
Here, we'll discuss how GitHub Script lets you automate common GitHub processes using GitHub Actions workflows.
1+
In this unit, you'll learn how GitHub Script enables you to automate common GitHub processes by using GitHub Actions workflows.
22

33
## What is GitHub Script?
44

5-
[GitHub Script](https://github.com/actions/github-script?azure-portal=true) is an action that provides an authenticated [octokit](https://octokit.github.io/rest.js/?azure-portal=true) client and allows JavaScript to be written directly in a workflow file. It runs in [Node.js](https://nodejs.org/?azure-portal=true), so you have the power of that platform available when writing scripts.
5+
[GitHub Script](https://github.com/actions/github-script?azure-portal=true) is an action that provides an authenticated [Octokit](https://octokit.github.io/rest.js/?azure-portal=true) client and enables JavaScript to be written directly in a workflow file. It runs in [Node.js](https://nodejs.org/?azure-portal=true), so you have the power of that platform available when you write scripts.
66

7-
## What is octokit?
7+
## What is Octokit?
88

9-
octokit is the official collection of clients for the GitHub API. One of these clients, rest.js, provides JavaScript access to GitHub's REST interface.
9+
Octokit is the official collection of clients for the GitHub API. One of these clients, rest.js, provides JavaScript access to the GitHub REST interface.
1010

1111
You have always been able to automate the GitHub API via octokit/rest.js, although it could be a chore to properly set up and maintain. One of the great advantages to using GitHub Script is that it handles all of this overhead so you can immediately start using the API. You don't need to worry about dependencies, configuration, or even authentication.
1212

1313
### What can octokit/rest.js do?
1414

15-
The short answer is that it can do virtually anything with respect to automating GitHub. Not only do you have access to commits, pull requests, and issues, but you also have access to users, projects, and organizations. You can retrieve lists of commonly used files, like popular licenses or `.gitignore` files. You can even render Markdown.
15+
The short answer is that it can do virtually anything with respect to automating GitHub. In addition to having access to commits, pull requests, and issues, you also have access to users, projects, and organizations. You can retrieve lists of commonly used files, like popular licenses or `.gitignore` files. You can even render Markdown.
1616

17-
If you're building something that integrates GitHub, the odds are good that you'll find what you're looking for in [the full octokit/rest.js documentation](https://octokit.github.io/rest.js/?azure-portal=true).
17+
If you're creating something that integrates GitHub, the odds are good that you'll find what you're looking for in [the full octokit/rest.js documentation](https://octokit.github.io/rest.js/?azure-portal=true).
1818

1919
### How is using GitHub Script different from octokit/rest.js?
2020

21-
The main difference in usage is that GitHub Script provides you with a preauthenticated octokit/rest.js client named `github`.
21+
The main difference in usage is that GitHub Script provides a preauthenticated octokit/rest.js client named `github`.
2222

23-
So instead of:
23+
So instead of
2424

2525
`octokit.issues.createComment({`
2626

27-
You'd use:
27+
you use
2828

29-
`github.issues.createComment({`
29+
`github.issues.createComment({`.
3030

3131
In addition to the `github` variable, the following variables are also provided:
3232

33-
- `context` is an object containing the [context of the workflow run](https://github.com/actions/toolkit/blob/master/packages/github/src/context.ts?azure-portal=true).
33+
- `context` is an object that contains the [context of the workflow run](https://github.com/actions/toolkit/blob/master/packages/github/src/context.ts?azure-portal=true).
3434
- `core` is a reference to the [@actions/core](https://github.com/actions/toolkit/tree/master/packages/core?azure-portal=true) package.
3535
- `io` is a reference to the [@actions/io](https://github.com/actions/toolkit/tree/master/packages/io?azure-portal=true) package.
3636

37-
## Building a workflow that uses GitHub Script
37+
## Creating a workflow that uses GitHub Script
3838

39-
GitHub Script actions fit into a workflow like any other action. As a result, you can even mix them in with existing workflows, such as those you may already have set up for CI/CD. To illustrate its convenience, we'll now construct a complete workflow that uses GitHub Script to automatically post a comment to all newly created issues.
39+
GitHub Script actions fit into a workflow like any other action. As a result, you can even mix them in with existing workflows, like those you might have already set up for CI/CD. To illustrate the convenience of GitHub Script, you'll now construct a complete workflow that uses it to automatically post a comment to all newly created issues.
4040

41-
We'll start off with a `name` and an `on` clause that specifies that this workflow runs when issues are opened.
41+
You'll start off with a `name` and an `on` clause that specifies that the workflow runs when issues are opened:
4242

4343
```yaml
4444
name: Learning GitHub Script
@@ -48,7 +48,7 @@ on:
4848
types: [opened]
4949
```
5050
51-
Next, we'll define a job named `comment` that runs on Linux with a series of steps.
51+
Next, you'll define a job named `comment` that runs on Linux with a series of steps:
5252

5353
```yaml
5454
jobs:
@@ -72,25 +72,25 @@ In this case, there's only one step: the GitHub Script action.
7272
})
7373
```
7474

75-
Using GitHub Actions can really help automate the events that take place in your repositories. Imagine that a repository visitor opened a new issue containing information about a critical bug. You might want to thank them for bringing that to your attention; however, this simple task can become overwhelming as your repository attracts more visitors. By automating an issue comment, you could automate the process of thanking visitors every single time.
75+
Using GitHub Actions can really help automate the events that take place in your repositories. Imagine that a repository visitor opened a new issue containing information about a critical bug. You might want to thank them for bringing the bug to your attention, but this simple task can become overwhelming as your repository attracts more visitors. By automating an issue comment, you can automate the process of thanking visitors every time.
7676

7777
### Using actions/[email protected]
7878

79-
The `actions/[email protected]` action, also known as GitHub Script, does all the heavy lifting for our integration with the GitHub API.
79+
The `actions/[email protected]` action, also known as GitHub Script, does all the difficult work for your integration with the GitHub API.
8080

8181
This action requires a `github-token` that's provided at runtime so that requests are authenticated. This is automatically done for you, so you can use that code as-is.
8282

8383
The `script` parameter can be virtually any JavaScript that uses the octokit/rest/js client stored in `github`. In this case, it's just one line (split across multiple lines for readability) that creates a hardcoded comment.
8484

85-
After the workflow is run, GitHub Script logs the code it executed for review on the **Actions** tab.
85+
After the workflow runs, GitHub Script logs the code it ran for review on the **Actions** tab:
8686

87-
![Screenshot of a completed workflow using GitHub Script.](../media/2-completed-workflow.png)
87+
![Screenshot of a completed GitHub Script workflow.](../media/2-completed-workflow.png)
8888

8989
### Running from a separate file
9090

91-
Sometimes, you might need to use significant code to fulfill your GitHub Script scenario. When that happens, you can keep the script in a separate file and reference it from the workflow instead of putting all the script inline.
91+
You might sometimes need to use a significant amount of code to meet your GitHub Script scenario. When that happens, you can keep the script in a separate file and reference it from the workflow instead of putting all the script inline.
9292

93-
Here's an example of a simple workflow that does this:
93+
Here's an example of a simple workflow that uses that technique:
9494

9595
```yaml
9696
on: push

0 commit comments

Comments
 (0)