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
{{ message }}
This repository was archived by the owner on Sep 1, 2022. It is now read-only.
Great job @{{user.login}}, you successfully added a workflow to this repository 🎉! Adding that file to this branch is enough for GitHub Actions to begin running. The time this takes will vary based on the complexity of the workflow.
4
+
5
+
At this point we can ignore the workflow because it doesn't do anything yet 😢, but we will be modifying it many times to explore using GitHub Script.
6
+
7
+
---
8
+
9
+
If you want to inspect the workflows that are configured in this repository, you can do so by heading over to the [Actions tab]({{actionsUrl}}) of this repository.
### :keyboard: Activity: Create a pull request to prepare the repository for actions
4
+
5
+
1. Create a new workflow file titled `my-workflow.yml` by using the instructions below, or [this quicklink]({{quicklink}}).
6
+
- Go to the [Actions tab]({{ actionsUrl }}).
7
+
- Choose the **Set up a workflow yourself** option, located on the top right hand corner of the screen.
8
+
- Change the name of the file from `main.yml` to `my-workflow.yml`.
9
+
1. Commit the workflow to a new branch.
10
+
1. Create a pull request titled **Create my-workflow.yml**.
11
+
1. Supply the pull request body content and click `Create pull request`.
12
+
13
+
_It is important to place meaningful content into the body of the pull requests you create throughout this course. This repository will stay with you long after you complete the course. It is advisable that you use the body of the pull requests you create as a way to take long lived notes about thing you want to remember._
14
+
15
+
<details><summary>Suggested body content</summary>
16
+
17
+
`Workflow files are the recipe for task automation. This is where actions are placed if I want to use them for a task.`
18
+
19
+
</details>
20
+
21
+
I'll respond in the new pull request when I detect it has been created.
22
+
23
+
---
24
+
25
+
If at any point you're expecting a response and don't see one, refresh the page.
Hello @{{user.login}}, I'm so excited to teach you how to use GitHub Script in your workflows 😄
4
+
5
+
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.
6
+
7
+
#### What is a workflow file?
8
+
9
+
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.
10
+
11
+
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.
12
+
13
+
_In our case, we will use this one **workflow** file for many things, which leads us to break this convention for teaching purposes._
14
+
15
+
---
16
+
17
+
<!-- 💻 Actively learn about workflows by enrolling in [this Learning Lab course which has no name or content yet]() -->
18
+
19
+
📖 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)
Currently `my-workflow.yml` is not set up correctly for our use-case. Before we make any changes now is a good time to answer **what is GitHub Script?**
4
+
5
+
**GitHub Script**
6
+
7
+
[GitHub Script](https://github.com/actions/github-script) is a really awesome action that allows you to quickly interact with the GitHub API directly in your workflow!
8
+
9
+
You can think of this as a way to run simple functions without the need to build a bulky custom action to do so.
10
+
11
+
📖 See [octokit/rest.js](https://octokit.github.io/rest.js/) for the API client
12
+
documentation.
13
+
14
+
### :keyboard: Activity: Use GitHub Script in a workflow to comment on an issue
15
+
16
+
1.[Edit]({{workflowFile}}) the `.github/workflows/my-workflow.yml` so that it has the contents below:
17
+
18
+
```yaml
19
+
name: Learning GitHub Script
20
+
21
+
on:
22
+
issues:
23
+
types: [opened]
24
+
25
+
jobs:
26
+
comment:
27
+
runs-on: ubuntu-latest
28
+
steps:
29
+
- uses: actions/github-script@0.8.0
30
+
with:
31
+
github-token: ${{secrets.GITHUB_TOKEN}}
32
+
script: |
33
+
github.issues.createComment({
34
+
issue_number: context.issue.number,
35
+
owner: context.repo.owner,
36
+
repo: context.repo.repo,
37
+
body: '🎉 You've created this issue comment using GitHub Script!!!'
38
+
})
39
+
```
40
+
41
+
1. Commit these file changes to this branch
42
+
43
+
---
44
+
45
+
I'll respond in this pull request once you make these changes.
0 commit comments