Prerequisites
- For general information about environments, see Deploying with GitHub Actions.
- For information about available rules, see Deployments and environments.
Creating an environment
Pour configurer un environnement dans un référentiel de comptes personnels, vous devez être le propriétaire du référentiel. Pour configurer un environnement dans un référentiel d’organisation, vous devez disposer d’un accès admin
.
-
Sur GitHub, accédez à la page principale du référentiel.
-
Sous le nom de votre dépôt, cliquez sur Paramètres. Si vous ne voyez pas l’onglet « Paramètres », sélectionnez le menu déroulant , puis cliquez sur Paramètres.
-
Dans la barre latérale gauche, cliquez sur Environnements.
-
Cliquez sur Nouvel environnement.
-
Entrez un nom pour l’environnement, puis cliquez sur Configurer l’environnement. Les noms d’environnements ne respectent pas la casse. Un nom d’environnement ne peut pas dépasser 255 caractères et doit être unique dans le dépôt.
-
Optionally, specify people or teams that must approve workflow jobs that use this environment. For more information, see Deployments and environments.
- Select Required reviewers.
- Enter up to 6 people or teams. Only one of the required reviewers needs to approve the job for it to proceed.
- Optionally, to prevent users from approving workflows runs that they triggered, select Prevent self-review.
- Click Save protection rules.
-
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.
- Select Wait timer.
- Enter the number of minutes to wait.
- Click Save protection rules.
-
Optionally, disallow bypassing configured protection rules. For more information, see Deployments and environments.
- Deselect Allow administrators to bypass configured protection rules.
- Click Save protection rules.
-
Optionally, enable any custom deployment protection rules that have been created with GitHub Apps. For more information, see Deployments and environments.
- Select the custom protection rule you want to enable.
- Click Save protection rules.
-
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.
Remarque
Les modèles de nom doivent être configurés individuellement pour les branches ou les balises.
-
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.
- Under Environment secrets, click Add Secret.
- Enter the secret name.
- Enter the secret value.
- Click Add secret.
-
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.- Under Environment variables, click Add Variable.
- Enter the variable name.
- Enter the variable value.
- Click Add variable.
You can also create and configure environments through the REST API. For more information, see Points de terminaison d’API REST pour les environnements de déploiement, Points de terminaison REST pour l’API secrets GitHub Actions, Points de terminaison d’API REST pour les variables GitHub Actions, and Points de terminaison d’API REST pour les stratégies de branche de déploiement.
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 environment
Pour configurer un environnement dans un référentiel de comptes personnels, vous devez être le propriétaire du référentiel. Pour configurer un environnement dans un référentiel d’organisation, vous devez disposer d’un accès admin
.
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.
-
Sur GitHub, accédez à la page principale du référentiel.
-
Sous le nom de votre dépôt, cliquez sur Paramètres. Si vous ne voyez pas l’onglet « Paramètres », sélectionnez le menu déroulant , puis cliquez sur Paramètres.
-
Dans la barre latérale gauche, cliquez sur Environnements.
-
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 Points de terminaison d’API REST pour les référentiels.
How environments relate to deployments
Quand un travail de workflow qui référence un environnement s’exécute, il crée un objet de déploiement avec la propriété environment
définie sur le nom de votre environnement. Au fur et à mesure que le workflow progresse, il crée aussi des objets d’état de déploiement avec la propriété environment
définie sur le nom de votre environnement, la propriété environment_url
définie sur l’URL de l’environnement (si elle est spécifiée dans le workflow) et la propriété state
définie sur l’état du travail.
You can access these objects through the REST API or GraphQL API. You can also subscribe to these webhook events. For more information, see Points de terminaison d’API REST pour les référentiels, Objets (GraphQL API), or Événements et charges utiles du webhook.
Next steps
GitHub Actions provides several features for managing your deployments. For more information, see Deploying with GitHub Actions.