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
The first step is always the hardest, so pick something easy!
5
-
Link to docs.github.com for further explanations.
6
-
Encourage users to open new tabs for steps!
7
-
-->
8
-
9
1
## Step 1: Create a workflow file
10
2
11
3
_Welcome to "Hello GitHub Actions"! :wave:_
@@ -20,24 +12,30 @@ _Welcome to "Hello GitHub Actions"! :wave:_
20
12
- To read more about workflows, jobs, and events, see "[Understanding GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions)".
21
13
- If you want to learn more about the `pull_request` event before using it, see "[pull_request](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request)".
22
14
23
-
To get you started, we used actions to go ahead and made a branch and pull request for you.
15
+
To get you started, we ran an Actions workflow in your new repository that, among other things, created a branch for you to work in, called `welcome-workflow`.
24
16
25
17
### :keyboard: Activity: Create a workflow file
26
18
27
19
1. Open a new browser tab, and navigate to this same repository. Then, work on the steps in your second tab while you read the instructions in this tab.
28
-
1. Create a pull request to view all the changes you'll make throughout this course. Click the **Pull Requests** tab, click **New pull request**, set `base: main` and `compare:welcome-workflow`, click **Create pull request**.
20
+
1. Create a pull request. This will contain all of the changes you'll make throughout this part of the course.
21
+
22
+
Click the **Pull Requests** tab, click **New pull request**, set `base: main` and `compare:welcome-workflow`, click **Create pull request**, then click **Create pull request** again.
23
+
29
24
1. Navigate to the **Code** tab.
30
25
1. From the **main** branch dropdown, click on the **welcome-workflow** branch.
31
26
1. Navigate to the `.github/workflows/` folder, then select **Add file** and click on **Create new file**.
32
-
1. In the **Name your file...** field, enter `welcome.yml`.
27
+
1. In the **Name your file** field, enter `welcome.yml`.
33
28
1. Add the following content to the `welcome.yml` file:
34
-
```yaml
29
+
30
+
```yaml copy
35
31
name: Post welcome comment
36
32
on:
37
33
pull_request:
38
34
types: [opened]
39
35
permissions:
40
36
pull-requests: write
41
37
```
42
-
1. To commit your changes, click **Commit new file**.
43
-
1. Wait about 20 seconds for actions to run, then refresh this page (the one you're following instructions from) and an action will automatically close this step and open the next one.
38
+
39
+
1. To commit your changes, click **Commit changes**.
40
+
1. Type a commit message, select **Commit directly to the welcome-workflow branch** and click **Commit changes**.
41
+
1. Wait about 20 seconds, then refresh this page (the one you're following instructions from). A separate Actions workflow in the repository (not the workflow you created) will run and will automatically replace this contents of this README file with instructions for the next step.
Start this step by acknowledging the previous step.
4
-
Define terms and link to docs.github.com.
5
-
Historic note: The previous course had troubleshooting steps for people not using the GitHub UI.
6
-
-->
7
-
8
1
## Step 2: Add a job to your workflow file
9
2
10
3
_Nice work! :tada: You added a workflow file!_
11
4
12
-
Here's what it means:
5
+
Here's what the entries in the `welcome.yml` file, on the `welcome-workflow` branch, mean:
13
6
14
-
-`name: Post welcome comment` gives your workflow a name. This name appears on any pull request or in the Actions tab of your repository.
15
-
-`on: pull_request: types: [opened]` indicates that your workflow will execute anytime a pull request opens in your repository.
7
+
-`name: Post welcome comment` gives your workflow a name. This name will appear in the Actions tab of your repository.
8
+
-`on: pull_request: types: [opened]` indicates that your workflow will execute whenever someone opens a pull request in your repository.
16
9
-`permissions` assigns the workflow permissions to operate on the repository
17
10
-`pull-requests: write` gives the workflow permission to write to pull requests. This is needed to create the welcome comment.
18
11
19
12
Next, we need to specify jobs to run.
20
13
21
-
**What is a _job_?**: A job is a set of steps in a workflow that execute on the same runner (a runner is a server that runs your workflows when triggered). Workflows have jobs, and jobs have steps. Steps are executed in order and are dependent on each other. We'll add steps in the next step of this exercise. To read more about jobs, see "[Jobs](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#jobs)".
14
+
**What is a _job_?**: A job is a set of steps in a workflow that execute on the same runner (a runner is a server that runs your workflows when triggered). Workflows have jobs, and jobs have steps. Steps are executed in order and are dependent on each other. You'll add steps to your workflow later in the course. To read more about jobs, see "[Jobs](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#jobs)".
22
15
23
-
In this step of our exercise, we will add a "build" job. We will specify `ubuntu-latest` as the fastest and cheapest job runner available. If you want to read more about why we'll use that runner, see the code explanation for the line `runs-on: ubuntu-latest` in the "[Understanding the workflow file](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#understanding-the-workflow-file)" article.
16
+
In the following activity, you'll add a "build" job to your workflow. You'll specify `ubuntu-latest` as the fastest, and cheapest, job runner available. If you want to read more about why we'll use that runner, see the code explanation for the line `runs-on: ubuntu-latest` in the "[Understanding the workflow file](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#understanding-the-workflow-file)" article.
24
17
25
18
### :keyboard: Activity: Add a job to your workflow file
26
19
27
-
1. Open your `welcome.yml` file.
28
-
2. Update the contents of the file to:
29
-
```yaml
20
+
1. In a separate browser tab, make sure you are on the `welcome-workflow` branch and open your `.github/workflows/welcome.yml` file.
21
+
1. Edit the file and update its contents to:
22
+
23
+
```yaml copy
30
24
name: Post welcome comment
31
25
on:
32
26
pull_request:
@@ -38,6 +32,7 @@ In this step of our exercise, we will add a "build" job. We will specify `ubuntu
38
32
name: Post welcome comment
39
33
runs-on: ubuntu-latest
40
34
```
41
-
3. Click **Commit changes...** in the top right of the workflow editor.
42
-
4. Type your commit message and commit your changes directly to your branch.
43
-
5. Wait about 20 seconds for actions to run, then refresh this page (the one you're following instructions from) and an action will automatically close this step and open the next one.
35
+
36
+
1. Click **Commit changes** in the top right of the workflow editor.
37
+
1. Type a commit message and commit your changes directly to the `welcome-workflow` branch.
38
+
1. Wait about 20 seconds, then refresh this page (the one you're following instructions from). Another workflow will run and will replace this content with instructions for the next step.
Start this step by acknowledging the previous step.
4
-
Define terms and link to docs.github.com.
5
-
-->
6
-
7
-
## Step 3: Add actions to your workflow file
1
+
## Step 3: Add a step to your workflow file
8
2
9
3
_Nice work adding a job to your workflow! :dancer:_
10
4
11
-
Workflows have jobs, and jobs have steps. So now we'll add steps to your workflow.
5
+
Workflows have jobs, and jobs have steps. So now we'll add a step to your workflow.
6
+
7
+
**What are _steps_?**: Actions steps run - in the order they are specified, from the top down - when a workflow job is processed. Each step must pass for the next step to run.
12
8
13
-
**What are _steps_?**: Actions steps will run during our job in order. Each step is either a shell script that will be executed, or an action that will be run. Each step must pass for the next step to run. Actions steps can be used from within the same repository, from any other public repository, or from a published Docker container image.
9
+
Each step consists of either a shell script that's executed, or a reference to an action that's run. When we talk about an action (with a lowercase "a") in this context, we mean a reusable unit of code. You can find out about actions in "[Finding and customizing actions](https://docs.github.com/en/actions/learn-github-actions/finding-and-customizing-actions)," but for now we'll use a shell script in our workflow step.
14
10
15
-
In our action, we post a comment on the pull request using a [bash](https://en.wikipedia.org/wiki/Bash_%28Unix_shell%29) script and [GitHub CLI](https://cli.github.com/).
11
+
Update your workflow to make it post a comment on new pull requests. It will do this using a [bash](https://en.wikipedia.org/wiki/Bash_%28Unix_shell%29) script and [GitHub CLI](https://cli.github.com/).
16
12
17
-
### :keyboard: Activity: Add Actions steps to your workflow file
13
+
### :keyboard: Activity: Add a step to your workflow file
18
14
19
-
1. Open your `welcome.yml` file.
20
-
2. Update the contents of the file to:
21
-
```yaml
15
+
1. Still working on the `welcome-workflow` branch, open your `welcome.yml` file.
16
+
1. Update the contents of the file to:
17
+
18
+
```yaml copy
22
19
name: Post welcome comment
23
20
on:
24
21
pull_request:
@@ -35,6 +32,9 @@ In our action, we post a comment on the pull request using a [bash](https://en.w
35
32
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36
33
PR_URL: ${{ github.event.pull_request.html_url }}
37
34
```
38
-
3. Click **Commit changes...** in the top right of the workflow editor.
39
-
4. Type your commit message and commit your changes directly to your branch.
40
-
5. Wait about 20 seconds for actions to run, then refresh this page (the one you're following instructions from) and an action will automatically close this step and open the next one.
35
+
36
+
**Note:** The step you've added uses GitHub CLI (`gh`) to add a comment when a pull request is opened. To allow GitHub CLI to post a comment, we set the `GITHUB_TOKEN` environment variable to the value of the `GITHUB_TOKEN` secret, which is an installation access token, created when the workflow runs. For more information, see "[Automatic token authentication](https://docs.github.com/en/actions/security-guides/automatic-token-authentication)." We set the `PR_URL` environment variable to the URL of the newly created pull request, and we use this in the `gh` command.
37
+
38
+
1. Click **Commit changes** in the top right of the workflow editor.
39
+
1. Type your commit message and commit your changes directly to your branch.
40
+
1. Wait about 20 seconds, then refresh this page (the one you're following instructions from). Another workflow will run and will replace this content with instructions for the next step.
Start this step by acknowledging the previous step.
4
-
Define terms and link to docs.github.com.
5
-
-->
6
-
7
1
## Step 4: Merge your workflow file
8
2
9
3
_You're now able to write and run an Actions workflow! :sparkles:_
@@ -16,4 +10,4 @@ Merge your changes so the action will be a part of the `main` branch.
16
10
1. Click on the pull request you created in step 1.
17
11
1. Click **Merge pull request**, then click **Confirm merge**.
18
12
1. Optionally, click **Delete branch** to delete your `welcome-workflow` branch.
19
-
1. Wait about 20 seconds for actions to run, then refresh this page (the one you're following instructions from) and an action will automatically close this step and open the next one.
13
+
1. Wait about 20 seconds, then refresh this page (the one you're following instructions from). Another workflow will run and will replace this content with instructions for the next step.
Start this step by acknowledging the previous step.
4
-
Define terms and link to docs.github.com.
5
-
-->
6
-
7
1
## Step 5: Trigger the workflow
8
2
9
-
_You've now got a fully functioning workflow! :smile:_
3
+
_You've now added a fully functioning workflow to your repository! :smile:_
10
4
11
-
Your new action will run any time a pull request has been opened.
5
+
The shell script in the workflow will run whenever a new pull request is opened.
12
6
13
-
**Seeing your _action_ in action**: The status of your action is shown in a pull request before you merge, look for **All checks have passed** when you try out the steps below. You can also view them from the **Actions** tab in your repository. From there, you will see all the actions that have run, and you can click on each action to view details and access log files.
7
+
**Seeing your _action_ in action**: The status of each workflow run that's triggered is shown in the pull request before it's merged: look for **All checks have passed** when you try out the steps below. You can also see a list of all the workflows that are running, or have finished running, in the **Actions** tab of your repository. From there, you can click on each workflow run to view more details and access log files.
14
8
15
-

9
+

16
10
17
11
### :keyboard: Activity: Trigger the workflow
18
12
19
13
1. Make a new branch named `test-workflow`.
20
-
1. Commit any change to your branch, such as adding an emoji to your README.md file.
21
-
1. Create the pull request on your branch.
22
-
1. See your action run on your pull request.
23
-
1. Wait about 20 seconds for actions to run, then refresh this page (the one you're following instructions from) and an action will automatically close this step and open the next one.
14
+
1. Make a change, such as adding an emoji to your README.md file, and commit the change directly to your new branch.
15
+
1. In the **Pull requests** tab, create a pull request that will merge `test-workflow` into `main`.
16
+
1. Watch the workflow running in the checks section of the pull request.
17
+
1. Notice the comment that the workflow adds to the pull request.
18
+
1. Wait about 20 seconds, then refresh this page (the one you're following instructions from). Another workflow will run and will replace this content with instructions for the next step.
<img src=https://octodex.github.com/images/jetpacktocat.png alt="Mona the Octocat wearing a jetpack and smiling." width=300 align=right>
11
6
12
7
Here's a recap of all the tasks you've accomplished in your repository:
13
8
14
9
- You've created your first GitHub Actions workflow file.
15
10
- You learned where to make your workflow file.
16
-
- You created an event trigger, a job, and steps for your workflow.
11
+
- You defined an event trigger, a job, and a step for your workflow.
17
12
- You're ready to automate anything you can dream of.
18
13
19
14
### What's next?
20
15
21
-
- Learn more about GitHub Actions by reading "[Learn GitHub Actions](https://docs.github.com/actions/learn-github-actions)".
22
-
- Use actions created by others in [awesome-actions](https://github.com/sdras/awesome-actions).
23
-
- We'd love to hear what you thought of this course [in our discussion board](https://github.com/orgs/skills/discussions/categories/hello-github-actions).
24
-
-[Take another GitHub Skills course](https://github.com/skills).
25
-
- Learn more about GitHub by reading the "[Get started](https://docs.github.com/get-started)" docs.
26
-
- To find projects to contribute to, check out [GitHub Explore](https://github.com/explore).
16
+
- Learn more about GitHub Actions by reading "[Learn GitHub Actions](https://docs.github.com/actions/learn-github-actions)"
17
+
- Use actions created by others in [awesome-actions](https://github.com/sdras/awesome-actions)
18
+
- We'd love to hear what you thought of this course [in our discussion board](https://github.com/orgs/skills/discussions/categories/hello-github-actions)
19
+
-[Take another course on GitHub Actions](https://skills.github.com/#automate-workflows-with-github-actions)
20
+
- Learn more about GitHub by reading the "[Get started](https://docs.github.com/get-started)" docs
21
+
- To find projects to contribute to, check out [GitHub Explore](https://github.com/explore)
Copy file name to clipboardExpand all lines: README.md
+3-32Lines changed: 3 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,24 +1,11 @@
1
1
<header>
2
2
3
-
<!--
4
-
<<< Author notes: Course header >>>
5
-
Include a 1280x640 image, course title in sentence case, and a concise description in emphasis.
6
-
In your repository settings: enable template repository, add your 1280x640 social image, auto delete head branches.
7
-
Add your open source license, GitHub uses MIT license.
8
-
-->
9
-
10
3
# Hello GitHub Actions
11
4
12
-
_Create a GitHub Action and use it in a workflow._
5
+
_Create and run a GitHub Actions workflow._
13
6
14
7
</header>
15
8
16
-
<!--
17
-
<<< Author notes: Course start >>>
18
-
Include start button, a note about Actions minutes,
19
-
and tell the learner why they should take the course.
20
-
-->
21
-
22
9
## Welcome
23
10
24
11
Automation is key for streamlining your work processes, and [GitHub Actions](https://docs.github.com/actions) is the best way to supercharge your workflow.
1. Right-click **Start course** and open the link in a new tab.
@@ -61,11 +37,6 @@ In this course, you will:
61
37
62
38
<footer>
63
39
64
-
<!--
65
-
<<< Author notes: Footer >>>
66
-
Add a link to get support, GitHub status page, code of conduct, license link.
67
-
-->
68
-
69
40
---
70
41
71
42
Get help: [Post in our discussion board](https://github.com/orgs/skills/discussions/categories/hello-github-actions)•[Review the GitHub status page](https://www.githubstatus.com/)
0 commit comments