github / safe-settings

ISC License
599 stars 146 forks source link

Add support for GitHub Environments #544

Closed avelizmu closed 11 months ago

avelizmu commented 11 months ago

Add support for working with GitHub Environments. https://docs.github.com/en/rest/deployments/environments

Allows you to set environment name, wait_timer, prevent_self_review, reviewers, deployment_branch_policy, variables, and deployment_protection_rules.

Requested in issue #291

Included unit tests for this functionality.

Also added a small change to the mergeDeep file to allow handling null value as if it were undefined, since it failed to compare deployment_branch_policy: null and deployment_branch_policy: {protected_branches: true, custom_branch_policies: false}

Format is

environments:
- name: production
  wait_timer: 0
  prevent_self_review: true
  reviewers:
  - type: User
    id: 15
  - type: Team
    id: 1337
  deployment_branch_policy: #null also acceptable instead of values
    protected_branches: true
    custom_branch_policies: false
    # or
    protected_branches: false
    custom_branch_policies:
    - master
    - dev
  variables:
  - name: endpoint
    value: https://1.1.1.1
  - name: id
    value: "1984" # Important, only takes strings
  deployment_protection_rules:
  - appId: 12345