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-ci/includes/2b-github-actions-essential-features.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
Here, you'll learn how to use default and custom environment variables, custom scripts, cache dependencies, and pass artifact data between jobs. You'll also learn how to access the workflow logs from both the GitHub website and REST API endpoints.
1
+
Here, you learn how to use default and custom environment variables, custom scripts, cache dependencies, and pass artifact data between jobs. And learn how to access the workflow logs from both the GitHub website and REST API endpoints.
2
2
3
3
## Default environment variables and contexts
4
4
@@ -24,13 +24,13 @@ jobs:
24
24
- run: echo "Deploying to production server on branch $GITHUB_REF"
25
25
```
26
26
27
-
This example is using the `github.ref` context to check the branch that triggered the workflow. If the branch is `main`, the runner is executed and prints out "Deploying to production server on branch $GITHUB_REF". The default environment variable `$GITHUB_REF` is used in the runner to refer to the branch. Notice that default environment variables are all uppercase where context variables are all lowercase.
27
+
This example is using the `github.ref` context to check the branch that triggered the workflow. If the branch is `main`, the runner is executed and prints "Deploying to production server on branch $GITHUB_REF". The default environment variable `$GITHUB_REF` is used in the runner to refer to the branch. Notice that default environment variables are all uppercase where context variables are all lowercase.
28
28
29
29
<!-- INFOMAGNUS UPDATES for sub OD 1.4.2 go here. Source Material: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs -->
30
30
31
31
## The contextual information available in a workflow
32
32
33
-
Contexts allow you to access information about workflow runs, variables, runner environments, jobs, and steps. Each context is is an object that contains properties which can be other objects or strings. The contexts available include: `github`, `env`, `vars`, `job`, `jobs`, `steps`, `runner`, `secrets`, `strategy`, `matrix`, `needs` and `inputs`. The table below presents these contexts with their descriptions.
33
+
Contexts allow you to access information about workflow runs, variables, runner environments, jobs, and steps. Each context is is an object that contains properties which can be other objects or strings. The contexts available include: `github`, `env`, `vars`, `job`, `jobs`, `steps`, `runner`, `secrets`, `strategy`, `matrix`, `needs` and `inputs`. Here is a table presents these contexts with their descriptions.
@@ -39,7 +39,7 @@ env | Contains variables set in a workflow, job, or step. For more information,
39
39
vars | Contains variables set at the repository, organization, or environment levels. For more information, see [vars context](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#vars-context).
40
40
job | Information about the currently running job. For more information, see [job context](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#job-context).
41
41
jobs | For reusable workflows only, contains outputs of jobs from the reusable workflow. For more information, see [jobs context](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#jobs-context).
42
-
steps | Information about the steps that have been run in the current job. For more information, see [steps context](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#steps-context).
42
+
steps | Information about the steps that ran in the current job. For more information, see [steps context](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#steps-context).
43
43
runner | Information about the runner that is running the current job. For more information, see [runner context](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#runner-context).
44
44
secrets | Contains the names and values of secrets that are available to a workflow run. For more information, see [secrets context](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#secrets-context).
45
45
strategy | Information about the matrix execution strategy for the current job. For more information, see [strategy context](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#strategy-context).
@@ -50,7 +50,7 @@ inputs | Contains the inputs of a reusable or manually triggered workflow. For m
50
50
51
51
The different contexts are available throughout a workflow run. For example, the secrets context may only be used at certain places within a job. In addition, you may only use some functions in certain places. For example, the `hashFiles` function is not available everywhere.
52
52
53
-
The following table lists the restrictions on where each context and special function can be used within a workflow. The listed contexts are only available for the given workflow key, and you may not use them anywhere else. Unless listed below, you may use a function anywhere.
53
+
The following table lists the restrictions on where each context and special function can be used within a workflow. The listed contexts are only available for the given workflow key, and you may not use them anywhere else. Unless listed in the table here, you may use a function anywhere.
You can define environment variables that are scoped to the entire workflow utilizing `env` at the top level of the workflow file. Scoping the contents of a job within a workflow using `jobs.<job_id>.env`. As well you can scope an environment variable within at a specific step within a job utilizing `jobs.<job_id>.steps[*].env`.
115
115
116
-
Below is an example displaying all three scenarios in a workflow file:
116
+
Next is an example displaying all three scenarios in a workflow file:
117
117
118
118
```yml
119
119
name: Greeting on variable day
@@ -139,7 +139,7 @@ jobs:
139
139
140
140
## Use default context in a workflow
141
141
142
-
Default environment variables are set by GitHub and not defined in a workflow. They are thus available to use in a workflow in the appropriate context. Most of these variables, other than `CI`, begin with `GITHUB_*` or `RUNNER_*`. The latter two types cannot be overwritten. As well, these default variables have a corresponding, and similarly named, context property. For instance, the `RUNNER_*` series of default variables have a matching context property of `runner.*`. An example of accessing default variables in a workflow levaraging these methods can be viewed below:
142
+
Default environment variables are set by GitHub and not defined in a workflow. They are thus available to use in a workflow in the appropriate context. Most of these variables, other than `CI`, begin with `GITHUB_*` or `RUNNER_*`. The latter two types cannot be overwritten. As well, these default variables have a corresponding, and similarly named, context property. For instance, the `RUNNER_*` series of default variables have a matching context property of `runner.*`. An example of accessing default variables in a workflow leveraging these methods can be viewed here:
143
143
144
144
```yml
145
145
on: workflow_dispatch
@@ -164,7 +164,7 @@ You can pass customer environment variables from one step of a workflow job to s
164
164
165
165
The step that creates or updates the environment variable does not have access to the new value, but all subsequent steps in a job will have access.
166
166
167
-
You can view an example below:
167
+
You can view an example here:
168
168
169
169
```yml
170
170
steps:
@@ -185,14 +185,14 @@ steps:
185
185
You can add protection rules for environments defined for your GitHub repository. To add an environment, in your repository:
186
186
187
187
**1.** Click on **Settings**
188
-

188
+

189
189
190
190
**2.** Click on **Environment** on the left panel.
191
191
192
-

192
+

193
193
194
194
**3.** Use the **New environment** button to add and configure an environment and add protections.
195
-

195
+

196
196
197
197
### About environments
198
198
@@ -204,7 +204,7 @@ When a workflow references an environment, the environment will appear in the re
204
204
205
205
### Environment protection rules
206
206
207
-
Environment deployment protection rules require specific conditions to pass before a job referencing the environment can proceed. You can use deployment protection rules to require a manual approval, delay a job, or restrict the environment to certain branches. You can also create and implement custom protection rules powered by GitHub Apps to use third-party systems to control deployments referencing environments configured on GitHub. Below you will find further explanation of these protection rules:
207
+
Environment deployment protection rules require specific conditions to pass before a job referencing the environment can proceed. You can use deployment protection rules to require a manual approval, delay a job, or restrict the environment to certain branches. You can also create and implement custom protection rules powered by GitHub Apps to use third-party systems to control deployments referencing environments configured on GitHub. Next you will find further explanation of these protection rules:
208
208
209
209
1. **Required reviewers protection rules**: Use required reviewers to require a specific person or team to approve workflow jobs that reference the environment. You can list up to six users or teams as reviewers. The reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.
210
210
@@ -224,7 +224,7 @@ Environment deployment protection rules require specific conditions to pass befo
224
224
225
225
Once custom deployment protection rules have been created and installed on a repository, you can enable the custom deployment protection rule for any environment in the repository.
226
226
227
-

227
+

228
228
229
229
> **Note**
230
230
> If you are on a GitHub Free, GitHub Pro, or GitHub Team plan, the enviroment deployment projection rules are only available for public repositories; with the exception of branch & tag protection rules. For users of GitHub Pro or GitHub Team plans, branch and tag protection rules are also available for private repositories.
@@ -342,7 +342,7 @@ GET /repos/{owner}/{repo}/actions/runs/{run_id}/logs
342
342
343
343
<!-- INFOMAGNUS UPDATES for sub OD 1.4.4 go here. Source Material: Infomagnus team to find source material and cite sources when they update material https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-an-installation-access-token-for-a-github-app , https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation -->
344
344
345
-
## Identify when to use an an installation token from a GitHub App
345
+
## Identify when to use an installation token from a GitHub App
346
346
347
347
Once your GitHub App is installed on an account, you can authenticate it as an app installation using the 'installation access token' for REST and GraphQL API requests. This allows the app to access resources owned by the installation, assuming the app was granted the necessary repository access and permissions. REST or GraphQL API requests made by an app installation are attributed to the app. In the following example, you replace `INSTALLATION_ACCESS_TOKEN` with the installation access token:
348
348
@@ -354,7 +354,7 @@ curl --request GET \
354
354
--header "X-GitHub-Api-Version: 2022-11-28"
355
355
```
356
356
357
-
You can also use an installation access token to authenticate for HTTP-based Git access. Your app must have the 'Contents' repository permission. You can then use the installation access token as the HTTP password. You replace TOKEN in the example below with the with the installation access token:
357
+
You can also use an installation access token to authenticate for HTTP-based Git access. Your app must have the 'Contents' repository permission. You can then use the installation access token as the HTTP password. You replace TOKEN in the example with the installation access token:
0 commit comments