You can create environments and secure those environments with deployment protection rules. A job that references an environment must follow any protection rules for the environment before running or accessing the environment's secrets.
Who can use this feature?Environments, environment secrets, and deployment protection rules are available in public repositories for all current GitHub plans. They are not available on legacy plans, such as Bronze, Silver, or Gold. For access to environments, environment secrets, and deployment branches in private or internal repositories, you must use GitHub Pro, GitHub Team, or GitHub Enterprise. If you are on a GitHub Free, GitHub Pro, or GitHub Team plan, other deployment protection rules, such as a wait timer or required reviewers, are only available for public repositories.
PrerequisitesNote
Users with GitHub Free plans can only configure environments for public repositories. If you convert a repository from public to private, any configured protection rules or environment secrets will be ignored, and you will not be able to configure any environments. If you convert your repository back to public, you will have access to any previously configured protection rules and environment secrets.
Organizations with GitHub Team and users with GitHub Pro can configure environments for private repositories. For more information, see GitHub’s plans.
To configure an environment in a personal account repository, you must be the repository owner. To configure an environment in an organization repository, you must have admin
access.
Note
On GitHub, navigate to the main page of the repository.
Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.
In the left sidebar, click Environments.
Click New environment.
Enter a name for the environment, then click Configure environment. Environment names are not case sensitive. An environment name may not exceed 255 characters and must be unique within the repository.
Optionally, specify people or teams that must approve workflow jobs that use this environment. For more information, see Deployments and environments.
Optionally, specify the amount of time to wait before allowing workflow jobs that use this environment to proceed. For more information, see Deployments and environments.
Optionally, disallow bypassing configured protection rules. For more information, see Deployments and environments.
Optionally, enable any custom deployment protection rules that have been created with GitHub Apps. For more information, see Deployments and environments.
Optionally, specify what branches and tags can deploy to this environment. For more information, see Deployments and environments.
Select the desired option in the Deployment branches dropdown.
If you chose Selected branches and tags, to add a new rule, click Add deployment branch or tag rule
In the "Ref type" dropdown menu, depending on what rule you want to apply, click Branch or Tag.
Enter the name pattern for the branch or tag that you want to allow.
Note
Name patterns must be configured for branches or tags individually.
Click Add rule.
Optionally, add environment secrets. These secrets are only available to workflow jobs that use the environment. Additionally, workflow jobs that use this environment can only access these secrets after any configured rules (for example, required reviewers) pass. For more information, see Deployments and environments.
Optionally, add environment variables. These variables are only available to workflow jobs that use the environment, and are only accessible using the vars
context. For more information, see Deployments and environments.
You can also create and configure environments through the REST API. For more information, see REST API endpoints for deployment environments, REST API endpoints for GitHub Actions Secrets, REST API endpoints for GitHub Actions variables, and REST API endpoints for deployment branch policies.
Running a workflow that references an environment that does not exist will create an environment with the referenced name. If the environment is created from running implicit page builds (for example, from a branch or folder source), the source branch will be added as a protection rule to the environment. Otherwise, the newly created environment will not have any protection rules or secrets configured. Anyone that can edit workflows in the repository can create environments via a workflow file, but only repository admins can configure the environment.
Deleting an environmentTo configure an environment in a personal account repository, you must be the repository owner. To configure an environment in an organization repository, you must have admin
access.
Deleting an environment will delete all secrets and protection rules associated with the environment. Any jobs currently waiting because of protection rules from the deleted environment will automatically fail.
On GitHub, navigate to the main page of the repository.
Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.
In the left sidebar, click Environments.
Next to the environment that you want to delete, click .
Click I understand, delete this environment.
You can also delete environments through the REST API. For more information, see REST API endpoints for repositories.
How environments relate to deploymentsWhen a workflow job that references an environment runs, it creates a deployment object with the environment
property set to the name of your environment. As the workflow progresses, it also creates deployment status objects with the environment
property set to the name of your environment, the environment_url
property set to the URL for environment (if specified in the workflow), and the state
property set to the status of the job.
You can access these objects through the REST API or GraphQL API. You can also subscribe to these webhook events. For more information, see REST API endpoints for repositories, Objects (GraphQL API), or Webhook events and payloads.
Next stepsGitHub Actions provides several features for managing your deployments. For more information, see Deploying with GitHub Actions.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4