Skip to content

Commit 84e7f9c

Browse files
salmanmkcsalilsubjc-clarkCopilotsaritai
authored
docs: document deployment: false for environments without deployments (#60278)
Co-authored-by: Salil <salilsub@users.noreply.github.com> Co-authored-by: Joe Clark <31087804+jc-clark@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Sarita Iyer <66540150+saritai@users.noreply.github.com>
1 parent 9b2f0aa commit 84e7f9c

File tree

5 files changed

+93
-3
lines changed

5 files changed

+93
-3
lines changed

content/actions/how-tos/deploy/configure-and-manage-deployments/control-deployments.md

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Deploying with GitHub Actions
33
shortTitle: Control deployments
4-
intro: Learn how to control deployments with features like environments and concurrency.
4+
intro: '{% data variables.product.prodname_actions %} gives you fine-grained control over deployments with environments, concurrency groups, and protection rules.'
55
versions:
66
fpt: '*'
77
ghes: '*'
@@ -54,8 +54,54 @@ You can configure environments with protection rules and secrets. When a workflo
5454
5555
Concurrency ensures that only a single job or workflow using the same concurrency group will run at a time. You can use concurrency so that an environment has a maximum of one deployment in progress and one deployment pending at a time. For more information about concurrency, see [AUTOTITLE](/actions/using-jobs/using-concurrency).
5656
57-
> [!NOTE]
58-
> `concurrency` and `environment` are not connected. The concurrency value can be any string; it does not need to be an environment name. Additionally, if another workflow uses the same environment but does not specify concurrency, that workflow will not be subject to any concurrency rules.
57+
{% ifversion actions-environments-without-deployments %}
58+
59+
## Using environments without deployments
60+
61+
By default, when a workflow job references an environment, {% data variables.product.company_short %} creates a deployment object to track the deployment. You can opt out of deployment creation by setting `deployment` to `false` in the environment configuration. The valid values are `true` (default) and `false`. You can also use an expression, for example `deployment: {% raw %}${{ github.ref_name == 'main' }}{% endraw %}`.
62+
63+
```yaml
64+
jobs:
65+
test:
66+
runs-on: ubuntu-latest
67+
environment:
68+
name: staging
69+
deployment: false
70+
steps:
71+
- name: run tests
72+
env:
73+
API_KEY: {% raw %}${{ secrets.API_KEY }}{% endraw %}
74+
run: echo "Running tests with staging secrets"
75+
```
76+
77+
When `deployment` is set to `false`:
78+
79+
* The job has full access to environment secrets and variables.
80+
* No {% data variables.product.github %} deployment object is created—the deployment history for the environment is not updated.
81+
* Wait timer protection rules still apply—the job waits for the configured duration.
82+
* Required reviewers still apply—reviewers must still approve before the job runs.
83+
84+
This is useful when you want to use environments for:
85+
86+
* **Organizing secrets**—group related secrets under an environment name without creating deployment records.
87+
* **Access control**—restrict which branches can use certain secrets via environment branch policies, without deployment tracking.
88+
* **CI and testing jobs**—reference an environment for its configuration without adding noise to the deployment history.
89+
90+
### Interaction with protection rules
91+
92+
The `deployment` property controls which protection rules apply:
93+
94+
| Protection rule | `deployment: true` (default) | `deployment: false` |
95+
|----------------|------------------------------|---------------------|
96+
| **None** | Deployment created, job runs | No deployment, job runs |
97+
| **Wait timer** | Wait timer enforced | Wait timer still enforced |
98+
| **Required reviewers** | Reviewers must approve | Reviewers must approve |
99+
| **Custom deployment protection rule app** | App webhook sent, must approve | **Job fails with error** |
100+
101+
Custom deployment protection rules ({% data variables.product.prodname_github_apps %}) require a deployment object to function. If you set `deployment: false` on an environment that has custom deployment protection rules, the job will fail immediately with an annotation or error message explaining that the environment's protection rules are incompatible with `deployment: false`. Either remove `deployment: false` from your workflow, or remove the custom deployment protection rules from the environment.
102+
103+
Note that `concurrency` and `environment` are not connected. The concurrency value can be any string; it does not need to be an environment name. Additionally, if another workflow uses the same environment but does not specify concurrency, that workflow will not be subject to any concurrency rules.
104+
{% endif %}
59105

60106
For example, when the following workflow runs, it will be paused with the status `pending` if any job or workflow that uses the `production` concurrency group is in progress. It will also cancel any job or workflow that uses the `production` concurrency group and has the status `pending`. This means that there will be a maximum of one running and one pending job or workflow in that uses the `production` concurrency group.
61107

content/actions/how-tos/deploy/configure-and-manage-deployments/create-custom-protection-rules.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ For general information about deployment protection rules, see [AUTOTITLE](/acti
4040

4141
Once a workflow reaches a job that references an environment that has the custom deployment protection rule enabled, {% data variables.product.company_short %} sends a `POST` request to a URL you configure containing the `deployment_protection_rule` payload. You can write your deployment protection rule to automatically send REST API requests that approve or reject the deployment based on the `deployment_protection_rule` payload. Configure your REST API requests as follows.
4242

43+
{% ifversion actions-environments-without-deployments %}
44+
45+
Custom deployment protection rules are not compatible when a workflow job's environment is set to `deployment: false`. For more information, see [AUTOTITLE](/actions/how-tos/deploy/configure-and-manage-deployments/control-deployments#interaction-with-protection-rules).
46+
47+
{% endif %}
48+
4349
1. Validate the incoming `POST` request. For more information, see [AUTOTITLE](/webhooks-and-events/webhooks/securing-your-webhooks#validating-payloads-from-github).
4450
1. Use a JSON Web Token to authenticate as a {% data variables.product.prodname_github_app %}. For more information, see [AUTOTITLE](/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app#about-authentication-as-a-github-app).
4551
1. Using the installation ID from the `deployment_protection_rule` webhook payload, generate an install token. For more information, see [AUTOTITLE](/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app).

content/actions/how-tos/write-workflows/choose-what-workflows-do/deploy-to-environment.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,19 @@ You need to create an environment before you can use it in a workflow. See [AUTO
4747
* On the deployments page for the repository
4848
* In the visualization graph for the workflow run
4949
* (If a pull request triggers the workflow) As a "View deployment" button in the pull request timeline
50+
51+
{% ifversion actions-environments-without-deployments %}
52+
53+
1. Optionally, prevent a deployment object from being created by adding the `deployment` property. When set to `false`, the job still has access to environment secrets and variables, but no {% data variables.product.github %} deployment is created:
54+
55+
```yaml copy
56+
jobs:
57+
JOB-ID:
58+
environment:
59+
name: ENVIRONMENT-NAME
60+
deployment: false
61+
```
62+
63+
This is useful for CI or testing jobs that need environment secrets but aren't actually deploying anything. For more information, see [AUTOTITLE](/actions/how-tos/deploy/configure-and-manage-deployments/control-deployments#using-environments-without-deployments).
64+
65+
{% endif %}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Reference: https://github.com/github/docs-internal/pull/60278
2+
# The `deployment` property on environments allows opting out of deployment creation.
3+
versions:
4+
fpt: '*'
5+
ghec: '*'

data/reusables/actions/jobs/section-using-environments-for-jobs.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,20 @@ environment:
4949
```
5050

5151
{% endraw %}
52+
53+
{% ifversion actions-environments-without-deployments %}
54+
55+
### Example: Using an environment without creating a deployment
56+
57+
Set `deployment` to `false` to use an environment's secrets and variables without creating a deployment object.
58+
59+
```yaml
60+
environment:
61+
name: testing
62+
deployment: false
63+
```
64+
65+
Setting `deployment: false` is not compatible with custom deployment protection rules.
66+
For more information, see [AUTOTITLE](/actions/how-tos/deploy/configure-and-manage-deployments/control-deployments#using-environments-without-deployments).
67+
68+
{% endif %}

0 commit comments

Comments
 (0)