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
Copy file name to clipboardExpand all lines: learn-pr/github/github-actions-automate-tasks/includes/2-github-actions-automate-development-tasks.md
+38-34Lines changed: 38 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
Here, we'll introduce GitHub Actions and workflows. You'll learn the types of actions you can use and where to find them. You'll also look at examples of these types of actions and how they fit in a workflow.
1
+
Here, we introduce GitHub Actions and workflows. You learn the types of actions you can use and where to find them. You also look at examples of these types of actions and how they fit in a workflow.
2
2
3
3
## GitHub decreases time from idea to deployment
4
4
5
-
GitHub is designed to help teams of developers and DevOps engineers build and deploy applications quickly. There are many features in GitHub that enable this, but they generally fall into one of two categories:
5
+
GitHub is designed to help teams of developers and DevOps engineers build and deploy applications quickly. There are many features in GitHub that enable these efficiencies, but they generally fall into one of two categories:
6
6
7
7
-**Communication**: Consider all of the ways that GitHub makes it easy for a team of developers to communicate about the software development project: code reviews in pull requests, GitHub issues, project boards, wikis, notifications, and so on.
8
8
-**Automation**: GitHub Actions lets your team automate workflows at every step in the software-development process, from integration to delivery to deployment. It even lets you automate adding labels to pull requests and checking for stale issues and pull requests.
@@ -11,21 +11,21 @@ When combined, these features have allowed thousands of development teams to eff
11
11
12
12
## Use workflow automation to decrease development time
13
13
14
-
We'll focus on automation in this module. Let's take a moment to understand how teams can use automation to reduce the amount of time it takes to complete a typical development and deployment workflow.
14
+
In this module, we focus on automation. Let's take a moment to understand how teams can use automation to reduce the amount of time it takes to complete a typical development and deployment workflow.
15
15
16
-
Consider all of the tasks that must happen *after* the code is written, but before you can reliably use the code for its intended purpose. Depending on your organization's goals, you'll likely need to perform one or more of the following tasks:
16
+
Consider all of the tasks that must happen *after* the code is written, but before you can reliably use the code for its intended purpose. Depending on your organization's goals, you likely need to perform one or more of the following tasks:
17
17
18
18
- Ensure the code passes all unit tests.
19
19
- Perform code quality and compliance checks to make sure the source code meets the organization's standards.
20
20
- Check the code and its dependencies for known security issues.
21
-
- Build the code integrating new source from (potentially) multiple contributors.
21
+
- Build the code by integrating new source code from (potentially) multiple contributors.
22
22
- Ensure the software passes integration tests.
23
-
-Version the new build.
23
+
-Specify the version of the new build.
24
24
- Deliver the new binaries to the appropriate filesystem location.
25
25
- Deploy the new binaries to one or more servers.
26
-
-If any of these tasks don't pass, report the issue to the proper individual or team for resolution.
26
+
-Determine if any of these tasks don't pass, and report the issue to the proper individual or team for resolution.
27
27
28
-
The challenge is to do these tasks reliably, consistently, and in a sustainable manner. This is an ideal job for workflow automation. If you're already relying on GitHub, you'll likely want to set up your workflow automation using GitHub Actions.
28
+
The challenge is to do these tasks reliably, consistently, and in a sustainable manner. This process is an ideal job for workflow automation. If you're already relying on GitHub, you likely want to set up your workflow automation using GitHub Actions.
29
29
30
30
## What is GitHub Actions?
31
31
@@ -48,8 +48,8 @@ However, beyond those GitHub Actions featured on the Actions tab, you can:
48
48
Many GitHub Actions are open source and available for anyone who wants to use them. However, just like with any open-source software, you need to carefully check them before using them in your project. Similar to recommended community standards with open-source software such as including a README, code of conduct, contributing file, and issue templates, you can follow these recommendations when using GitHub Actions:
49
49
50
50
- Review the action's `action.yml` file for inputs, outputs, and to make sure the code does what it says it does.
51
-
- Check if the action is in the GitHub Marketplace. This is a good check, even if an action doesn't have to be on the GitHub Marketplace to be valid.
52
-
- Check if the action is verified in the GitHub Marketplace. This means that GitHub has approved the use of this action. However, you should still review it before using it.
51
+
- Check if the action is in the GitHub Marketplace. This check is worthwhile, even if an action doesn't have to be on the GitHub Marketplace to be valid.
52
+
- Check if the action is verified in the GitHub Marketplace. Verification means that GitHub approved the use of this action. However, you should still review it before using it.
53
53
- Include the version of the action you're using by specifying a Git ref, SHA, or tag.
54
54
55
55
## Types of GitHub actions
@@ -58,7 +58,7 @@ There are three types of GitHub actions: container actions, JavaScript actions,
58
58
59
59
With **container actions**, the environment is part of the action's code. These actions can only be run in a Linux environment that GitHub hosts. Container actions support many different languages.
60
60
61
-
**JavaScript actions** don't include the environment in the code. You'll have to specify the environment to execute these actions. You can run these actions in a VM (virtual machine) in the cloud or on-premises. JavaScript actions support Linux, macOS, and Windows environments.
61
+
**JavaScript actions** don't include the environment in the code. You have to specify the environment to execute these actions. You can run these actions in a VM (virtual machine) in the cloud or on-premises. JavaScript actions support Linux, macOS, and Windows environments.
62
62
63
63
**Composite actions** allow you to combine multiple workflow steps within one action. For example, you can use this feature to bundle together multiple run commands into an action, and then have a workflow that executes the bundled commands as a single step using that action.
64
64
@@ -97,9 +97,9 @@ branding:
97
97
color: "purple"
98
98
```
99
99
100
-
Notice the ```inputs``` section. Here, you're getting the value of a variable called `MY_NAME`. This variable will be set in the workflow that runs this action.
100
+
Notice the ```inputs``` section. Here, you're getting the value of a variable called `MY_NAME`. This variable is set in the workflow that runs this action.
101
101
102
-
In the ```runs``` section, notice you specify *docker* in the ```uses``` attribute. When you do this, you'll need to provide the path to the Docker image file. Here, it's called *Dockerfile*. We won't get into the specifics of Docker here, but if you'd like more information, check out the [Introduction to Docker Containers](/training/modules/intro-to-docker-containers/?azure-portal=true) module.
102
+
In the ```runs``` section, notice you specify *docker* in the ```uses``` attribute. When you set this value, you need to provide the path to the Docker image file. In this case, *Dockerfile*. We're not covering the specifics of Docker here, but if you'd like more information, check out the [Introduction to Docker Containers](/training/modules/intro-to-docker-containers/?azure-portal=true) module.
103
103
104
104
The last section, *branding*, personalizes your action in the GitHub Marketplace if you decide to publish it there.
105
105
@@ -111,7 +111,7 @@ A *GitHub Actions workflow* is a process that you set up in your repository to a
111
111
112
112
To create a workflow, you add actions to a .yml file in the ```.github/workflows``` directory in your GitHub repository.
113
113
114
-
In the exercise coming up, your workflow file *main.yml* will look like this:
114
+
In the exercise coming up, your workflow file *main.yml* looks like this example:
115
115
116
116
```yml
117
117
name: A workflow for my Hello World file
@@ -127,7 +127,7 @@ jobs:
127
127
MY_NAME: "Mona"
128
128
```
129
129
130
-
Notice the ```on:``` attribute. This is a *trigger* to specify when this workflow will run. Here, it triggers a run when there's a push event to your repository. You can specify single events like ```on: push```, an array of events like ```on: [push, pull_request]```, or an event-configuration map that schedules a workflow or restricts the execution of a workflow to specific files, tags, or branch changes. The map might look something like this:
130
+
Notice the ```on:``` attribute, its value is a *trigger* to specify when this workflow runs. Here, it triggers a run when there's a push event to your repository. You can specify single events like ```on: push```, an array of events like ```on: [push, pull_request]```, or an event-configuration map that schedules a workflow or restricts the execution of a workflow to specific files, tags, or branch changes. The map might look something like this:
131
131
132
132
```yml
133
133
on:
@@ -146,33 +146,36 @@ on:
146
146
- created
147
147
```
148
148
149
-
An event will trigger on all activity types for the event unless you specify the type or types. For a comprehensive list of events and their activity types, see: [Events that trigger workflows](https://docs.github.com/actions/using-workflows/events-that-trigger-workflows?azure-portal=true) in the GitHub documentation.
149
+
An event triggers on all activity types for the event unless you specify the type or types. For a comprehensive list of events and their activity types, see: [Events that trigger workflows](https://docs.github.com/actions/using-workflows/events-that-trigger-workflows?azure-portal=true) in the GitHub documentation.
150
150
151
-
A workflow must have at least one *job*. A job is a section of the workflow associated with a *runner*. A runner can be GitHub-hosted or self-hosted, and the job can run on a machine or in a container. You'll specify the runner with the ```runs-on:``` attribute. Here, you're telling the workflow to run this job on ```ubuntu-latest```.
151
+
A workflow must have at least one *job*. A job is a section of the workflow associated with a *runner*. A runner can be GitHub-hosted or self-hosted, and the job can run on a machine or in a container. You specify the runner with the ```runs-on:``` attribute. Here, you're telling the workflow to run this job on ```ubuntu-latest```.
152
152
153
-
Each job will have steps to complete. In our example, the step uses the action *actions/checkout@v1* to check out the repository. What's interesting is the ```uses: ./action-a``` value, which is the path to the container action that you build in an *action.yml* file.
153
+
Each job has steps to complete. In our example, the step uses the action *actions/checkout@v1* to check out the repository. What's interesting is the ```uses: ./action-a``` value, which is the path to the container action that you build in an *action.yml* file.
154
154
155
155
The last part of this workflow file sets the `MY_NAME` variable value for this workflow. Recall the container action took an input called `MY_NAME`.
156
156
157
157
For more information on workflow syntax, see [Workflow syntax for GitHub Actions](https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions?azure-portal=true)
158
158
159
159
## GitHub-hosted versus self-hosted runners
160
160
161
-
We briefly mentioned runners as being associated with a job. A runner is simply a server that has the GitHub Actions runner application installed. In the previous workflow example, there was a `runs-on: ubuntu-latest` attribute within the jobs block, which told the workflow that the job will run using the GitHub-hosted runner that's running in the `ubuntu-latest` environment.
161
+
We briefly mentioned runners as being associated with a job. A runner is simply a server that has the GitHub Actions runner application installed. In the previous workflow example, there was a `runs-on: ubuntu-latest` attribute within the jobs block, which told the workflow that the job is going to run using the GitHub-hosted runner that's running in the `ubuntu-latest` environment.
162
162
163
-
When it comes to runners, there are two options from which to choose: GitHub-hosted runners or self-hosted runners. If you use a GitHub-hosted runner, each job runs in a fresh instance of a virtual environment. The GitHub-hosted runner type you define, `runs-on: {operating system-version}` then specifies that environment. With self-hosted runners, you need to apply the self-hosted label, its operating system, and the system architecture. For example, a self-hosted runner with a Linux operating system and ARM32 architecture would look like the following: `runs-on: [self-hosted, linux, ARM32]`.
163
+
When it comes to runners, there are two options from which to choose: GitHub-hosted runners or self-hosted runners. If you use a GitHub-hosted runner, each job runs in a fresh instance of a virtual environment. The GitHub-hosted runner type you define, `runs-on: {operating system-version}` then specifies that environment. With self-hosted runners, you need to apply the self-hosted label, its operating system, and the system architecture. For example, a self-hosted runner with a Linux operating system and ARM32 architecture would look like the following specification: `runs-on: [self-hosted, linux, ARM32]`.
164
164
165
-
Each type of runner has its benefits, but GitHub-hosted runners offer a quicker and simpler way to run your workflows, albeit with limited options. Self-hosted runners are a highly configurable way to run workflows in your own custom local environment. You can run self-hosted runners on-premises or in the cloud. You can also use self-hosted runners to create a custom hardware configuration with more processing power or memory. This will help to run larger jobs, install software available on your local network, and choose an operating system not offered by GitHub-hosted runners.
165
+
Each type of runner has its benefits, but GitHub-hosted runners offer a quicker and simpler way to run your workflows, albeit with limited options. Self-hosted runners are a highly configurable way to run workflows in your own custom local environment. You can run self-hosted runners on-premises or in the cloud. You can also use self-hosted runners to create a custom hardware configuration with more processing power or memory. This type of configuration helps to run larger jobs, install software available on your local network, and choose an operating system not offered by GitHub-hosted runners.
166
166
167
-
### GitHub Actions may have usage limits
167
+
### GitHub Actions can have usage limits
168
168
169
-
GitHub Actions has some usage limits, depending on your GitHub plan and whether your runner is GitHub-hosted or self-hosted. For more information on usage limits, check out [Usage limits, billing, and administration](https://docs.github.com/actions/reference/usage-limits-billing-and-administration) in the GitHub documentation.
169
+
GitHub Actions does have some usage limits, depending on your GitHub plan and whether your runner is GitHub-hosted or self-hosted. For more information on usage limits, check out [Usage limits, billing, and administration](https://docs.github.com/actions/reference/usage-limits-billing-and-administration) in the GitHub documentation.
170
170
171
171
## GitHub hosted larger runners
172
-
GitHub offers larger runners for workflows that require more resources. These runners are GitHub-hosted and provide increased CPU, memory, and disk space compared to standard runners. They are designed to handle resource-intensive workflows efficiently, ensuring optimal performance for demanding tasks.
172
+
173
+
GitHub offers larger runners for workflows that require more resources. These runners are GitHub-hosted and provide increased CPU, memory, and disk space compared to standard runners. They're designed to handle resource-intensive workflows efficiently, ensuring optimal performance for demanding tasks.
173
174
174
175
### Runner sizes and labels
176
+
175
177
Larger runners are available in multiple configurations, providing enhanced vCPUs, RAM, and SSD storage to meet diverse workflow requirements. These configurations are ideal for scenarios such as:
178
+
176
179
- Compiling large codebases with extensive source files.
177
180
- Running comprehensive test suites, including integration and end-to-end tests.
178
181
- Processing large datasets for data analysis or machine learning tasks.
@@ -193,30 +196,31 @@ jobs:
193
196
```
194
197
These larger runners maintain compatibility with existing workflows by including the same preinstalled tools as standard `ubuntu-latest` runners.
195
198
196
-
For more details on runner sizes for larger runners, refer to the GitHub documentation [https://docs.github.com/en/actions/using-github-hosted-runners/using-larger-runners/about-larger-runners#machine-sizes-for-larger-runners]
197
-
199
+
For more information about runner sizes for larger runners, see the [GitHub documentation](https://docs.github.com/en/actions/using-github-hosted-runners/using-larger-runners/about-larger-runners#machine-sizes-for-larger-runners)
198
200
199
201
### Managing larger runners
202
+
200
203
GitHub provides tools to manage larger runners effectively, ensuring optimal resource utilization and cost management. Here are some key aspects of managing larger runners:
201
204
202
205
#### Monitoring usage
206
+
203
207
You can monitor the usage of larger runners through the GitHub Actions usage page in your repository or organization settings. This page provides insights into the number of jobs run, the total runtime, and the associated costs.
204
208
205
209
#### Managing access
206
-
To control access to larger runners, you can configure repository or organization-level policies. This ensures that only authorized workflows or teams can use these high-resource runners.
210
+
211
+
To control access to larger runners, you can configure repository or organization-level policies. This configuration ensures that only authorized workflows or teams can use these high-resource runners.
207
212
208
213
#### Cost management
209
-
Larger runners incur additional costs based on their usage. To manage costs, consider the following:
214
+
215
+
Larger runners incur extra costs based on their usage. To manage costs, consider the following suggestions:
216
+
210
217
- Use larger runners only for workflows that require high resources.
211
-
- Optimize workflows to reduce runtime.
218
+
- Reduce runtime by optimizing workflows.
212
219
- Monitor billing details regularly to track expenses.
213
220
214
221
#### Scaling workflows
222
+
215
223
If your workflows require frequent use of larger runners, consider scaling strategies such as:
224
+
216
225
- Using self-hosted runners for predictable workloads.
217
226
- Splitting workflows into smaller jobs to distribute the load across standard runners.
0 commit comments