Skip to content

Commit ad494b2

Browse files
authored
Merge pull request #244 from github/checks-input-docs
Checks input docs
2 parents 677cced + 243c05c commit ad494b2

File tree

9 files changed

+79
-5
lines changed

9 files changed

+79
-5
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ As seen above, we have two steps. One for a noop deploy, and one for a regular d
274274
| `outdated_mode` | `false` | `"strict"` | The mode to use for determining if a branch is up-to-date or not before allowing deployments. This option is closely related to the `update_branch` input option above. There are three available modes to choose from: `pr_base`, `default_branch`, or `strict`. The default is `strict` to help ensure that deployments are using the most up-to-date code. Please see the [documentation](docs/outdated_mode.md) for more details. |
275275
| `required_contexts` | `false` | `"false"` | Manually enforce commit status checks before a deployment can continue. Only use this option if you wish to manually override the settings you have configured for your branch protection settings for your GitHub repository. Default is "false" - Example value: "context1,context2,context3" - In most cases you will not need to touch this option |
276276
| `skip_ci` | `false` | `""` | A comma separated list of environments that will not use passing CI as a requirement for deployment. Use this option to explicitly bypass branch protection settings for a certain environment in your repository. Default is an empty string `""` - Example: `"development,staging"` |
277+
| `checks` | `false` | `"all"` | This input defines how the branch-deploy Action will handle the status of CI checks on your PR/branch before deployments can continue. `"all"` requires that all CI checks must pass in order for a deployment to be triggered. `"required"` only waits for required CI checks to be passing. View the [documentation](docs/checks.md) for more details. |
277278
| `skip_reviews` | `false` | `""` | A comma separated list of environment that will not use reviews/approvals as a requirement for deployment. Use this options to explicitly bypass branch protection settings for a certain environment in your repository. Default is an empty string `""` - Example: `"development,staging"` |
278279
| `allow_forks` | `false` | `"true"` | Allow branch deployments to run on repository forks. If you want to harden your workflows, this option can be set to false. Default is "true" |
279280
| `admins` | `false` | `"false"` | A comma separated list of GitHub usernames or teams that should be considered admins by this Action. Admins can deploy pull requests without the need for branch protection approvals. Example: "monalisa,octocat,my-org/my-team" |

__tests__/functions/help.test.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ const defaultInputs = {
4545
draft_permitted_targets: '',
4646
admins: 'false',
4747
permissions: ['write', 'admin', 'maintain'],
48-
allow_sha_deployments: false
48+
allow_sha_deployments: false,
49+
checks: 'all'
4950
}
5051

5152
test('successfully calls help with defaults', async () => {
@@ -79,7 +80,8 @@ test('successfully calls help with non-defaults', async () => {
7980
draft_permitted_targets: 'development',
8081
admins: 'monalisa',
8182
permissions: ['write', 'admin', 'maintain'],
82-
allow_sha_deployments: true
83+
allow_sha_deployments: true,
84+
checks: 'all'
8385
}
8486

8587
expect(await help(octokit, context, 123, inputs))
@@ -112,7 +114,8 @@ test('successfully calls help with non-defaults', async () => {
112114
draft_permitted_targets: 'development',
113115
admins: 'monalisa',
114116
permissions: ['write', 'admin', 'maintain'],
115-
allow_sha_deployments: false
117+
allow_sha_deployments: false,
118+
checks: 'required'
116119
}
117120

118121
expect(await help(octokit, context, 123, inputs))

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ inputs:
9898
required: false
9999
default: ""
100100
checks:
101-
description: 'The mode to use for CI checks. "all" requires all checks to pass no matter what, "required" only waits for required checks.'
101+
description: 'This input defines how the branch-deploy Action will handle the status of CI checks on your PR/branch before deployments can continue. `"all"` requires that all CI checks must pass in order for a deployment to be triggered. `"required"` only waits for required CI checks to be passing. View the documentation (docs/checks.md) for more details.'
102102
required: false
103103
default: "all"
104104
skip_reviews:

dist/index.js

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
334 KB
Loading

docs/assets/required-ci-checks.png

214 KB
Loading

docs/checks.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Checks ✅
2+
3+
> This feature was originally requested via [#73](https://github.com/github/branch-deploy/issues/73)
4+
5+
The branch-deploy Action contains a useful input option to help give developers more control over how CI checks are handled during the deployment process. Some teams may have very strict controls over deployments and require **all status checks** to pass before a deployment can start. In this case, all CI checks must pass and that includes required, or non-required checks. Other teams may have a more relaxed approach and only require certain checks to pass before a deployment can start. This is where the `checks` input option comes in handy.
6+
7+
## Required CI Checks
8+
9+
First, let's explain what a "required" CI check is in case you're not familiar. A required CI check is a check that must pass before a pull request can be merged. This is a setting that can be configured in the repository settings under the "Branches" section. This section is shown in the screenshot below:
10+
11+
![required-ci-checks](assets/required-ci-checks.png)
12+
13+
> This example came directly from this respository's settings
14+
15+
So in this particular repository, the following CI checks are required:
16+
17+
- `test`
18+
- `package-check`
19+
- `lint`
20+
- `actions-config-validation`
21+
22+
Any other CI checks that run on a pull request are not required and are considered non-required checks.
23+
24+
## Using the `checks` Input Option
25+
26+
This section will contain a few examples of how you can use the `checks` option
27+
28+
### Example 1: All CI Checks Must Pass
29+
30+
This example shows how you can use the `checks` option to require all CI checks to pass before a deployment can start. This is the **default** behavior of the Action if you do not specify the `checks` option.
31+
32+
```yaml
33+
- name: branch-deploy
34+
uses: github/[email protected] # replace with the latest version of this Action
35+
id: branch-deploy
36+
with:
37+
checks: "all" # all CI checks (required or not) must pass before a deployment can start
38+
```
39+
40+
### Example 2: Only Required CI Checks Must Pass
41+
42+
This example shows how you can use the `checks` option to require only the **required** CI checks to pass before a deployment can start. This is useful if you have non-required checks that you don't want to block a deployment.
43+
44+
```yaml
45+
- name: branch-deploy
46+
uses: github/[email protected] # replace with the latest version of this Action
47+
id: branch-deploy
48+
with:
49+
checks: "required" # only required CI checks must pass before a deployment can start
50+
```
51+
52+
The screenshot below demonstrates how this option works in a real-world scenario. You can see how there are two CI checks defined on the pull request. One is called `test1` which is **required** and **passing**. The other is called `test2` which is **not required** and **failing**. Since the `checks` option is set to `required`, the deployment will start because the required check is passing and is the only status check taken into consideration for a deployment.
53+
54+
![required-ci-checks-example](assets/required-ci-checks-example.png)

src/functions/help.js

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ export async function help(octokit, context, reactionId, inputs) {
2727
required_contexts_message = `There are required contexts designated for this Action`
2828
}
2929

30+
var checks_message = defaultSpecificMessage
31+
if (inputs.checks.trim() === 'required') {
32+
checks_message = `Only required CI checks must pass before a deployment can be requested`
33+
} else {
34+
checks_message = `All CI checks must pass before a deployment can be requested`
35+
}
36+
3037
var skip_ci_message = defaultSpecificMessage
3138
if (inputs.skipCi.trim() !== '') {
3239
skip_ci_message = `This Action will not require passing CI for the environments specified`
@@ -181,6 +188,7 @@ export async function help(octokit, context, reactionId, inputs) {
181188
inputs.allowForks === 'true' ? 'run' : 'not run'
182189
} on forked repositories
183190
- \`skipCi: ${inputs.skipCi}\` - ${skip_ci_message}
191+
- \`checks: ${inputs.checks}\` - ${checks_message}
184192
- \`skipReviews: ${inputs.skipReviews}\` - ${skip_reviews_message}
185193
- \`draft_permitted_targets: ${
186194
inputs.draft_permitted_targets

0 commit comments

Comments
 (0)