Skip to content

[BUG]: github_actions_organization_permissions cannot disable Actions for all organization repositories #3417

Closed

Description

@deltreey

Expected Behavior

The provider should send the equivalent of:

{
    enabled_repositories": "none"
}

GitHub Actions should be disabled for all repositories in the organization.

Actual Behavior

Terraform plans successfully:

+ resource "github_actions_organization_permissions" "test" {
    + enabled_repositories = "none"
    + id                   = (known after apply)
    + sha_pinning_required = (known after apply)
  }

Apply fails:

Error: PUT https://api.example.ghe.com/orgs/example-org/actions/permissions: 422 Invalid request.

is not a member of ["all", "local_only", "selected"].

That validation error appears to refer to allowed_actions, not enabled_repositories.

Terraform Version

Terraform v1.15.0
on darwin_arm64

  • provider registry.terraform.io/integrations/github v6.12.1

Affected Resource(s)

  • github_actions_organization_permissions

Terraform Configuration Files

terraform {
  required_providers {
    github = {
      source  = "integrations/github"
      version = "6.12.1"
    }
  }
}

provider "github" {
  owner    = "example-org"
  base_url = "https://api.example.ghe.com/"
  token    = var.github_token
}

variable "github_token" {
  type      = string
  sensitive = true
}

with this setup:

resource "github_actions_organization_permissions" "test" {
  enabled_repositories = "none"
}

Notably, these others also fail

resource "github_actions_organization_permissions" "test" {
  enabled_repositories = "none"
  allowed_actions      = "all"
}


resource "github_actions_organization_permissions" "test" {
  enabled_repositories = "none"
  allowed_actions      = "local_only"
}


resource "github_actions_organization_permissions" "test" {
  enabled_repositories = "none"
  allowed_actions      = "selected"

  allowed_actions_config {
    github_owned_allowed = false
    verified_allowed     = false
    patterns_allowed     = []
  }
}

and even

resource "github_actions_organization_permissions" "test" {
  enabled_repositories = "none"
  allowed_actions      = "selected"

  allowed_actions_config {
    github_owned_allowed = false
    verified_allowed     = false
    patterns_allowed     = ["actions/checkout@*"]
  }
}

Steps to Reproduce

TF_VAR_github_token="<token>" terraform apply

Debug Output

I actually did more research than the above.

In `github/resource_github_actions_organization_permissions.go`, the provider always sets AllowedActions, even when allowed_actions is omitted:


allowedActions := d.Get("allowed_actions").(string)
enabledRepositories := d.Get("enabled_repositories").(string)

actionsPermissions := github.ActionsPermissions{
    AllowedActions:      &allowedActions,
    EnabledRepositories: &enabledRepositories,
}

Because allowed_actions is optional, d.Get("allowed_actions").(string) returns "" when omitted. The provider then appears to send allowed_actions: "", which GitHub rejects because valid values are only all, local_only, and selected.

This differs from the nearby repository-level Actions permissions resource, which avoids sending allowed_actions when Actions are disabled:

allowedActions := d.Get("allowed_actions").(string)
enabled := d.Get("enabled").(bool)

repoActionPermissions := github.ActionsPermissionsRepository{
    Enabled: &enabled,
}

// Only specify `allowed_actions` if actions are enabled
if enabled {
    repoActionPermissions.AllowedActions = &allowedActions
}

That pattern seems appropriate for organization-level permissions too. When enabled_repositories = "none", allowed_actions should not be sent unless the API explicitly requires it.

The provider also uses GetOk / non-empty checks elsewhere for optional string fields, for example:

if v, ok := d.GetOk("description"); ok && len(v.(string)) > 0 {
    milestone.Description = new(v.(string))
}


And this path is entirely untested. Current acceptance tests appear to cover:

enabled_repositories = "all"
enabled_repositories = "selected" with non-empty repository IDs
selected allowed-actions config

They do not appear to cover:

enabled_repositories = "none"
enabled_repositories = "selected" with repository_ids = []

Those two cases are important for deny-by-default organization baselines.

I tested this code change locally with Terraform provider development overrides, and it fixes the problem.

This configuration now applies successfully and immediately converges:

resource "github_actions_organization_permissions" "test" {
  enabled_repositories = "none"
}

Observed API response after apply:

{"enabled_repositories":"none","sha_pinning_required":false}

Follow-up terraform plan result:

No changes. Your infrastructure matches the configuration.
This configuration also applies successfully and immediately converges:

resource "github_actions_organization_permissions" "test" {
  enabled_repositories = "selected"
  allowed_actions      = "local_only"

  enabled_repositories_config {
    repository_ids = []
  }
}

Observed API response after apply:

{
  "enabled_repositories": "selected",
  "allowed_actions": "local_only"
}

Observed selected repository list after apply:

{"total_count":0,"repositories":[]}
Follow-up terraform plan result:

No changes. Your infrastructure matches the configuration.

Sketch:

func resourceGithubActionsEnabledRepositoriesObject(d *schema.ResourceData) ([]int64, error) {
    config := d.Get("enabled_repositories_config").([]any)
    if len(config) == 0 || config[0] == nil {
        return []int64{}, nil
    }

    data, ok := config[0].(map[string]any)
    if !ok {
        return []int64{}, nil
    }

    ids, ok := data["repository_ids"].(*schema.Set)
    if !ok || ids == nil {
        return []int64{}, nil
    }

    enabled := make([]int64, 0, ids.Len())
    for _, value := range ids.List() {
        enabled = append(enabled, int64(value.(int)))
    }

    return enabled, nil
}

Panic Output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    Type: Bug
    Status: Triage
    on May 11, 2026
  2. github-actions commented on May 11, 2026

    @github-actions

    👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

  3. deltreey commented on May 26, 2026

    @deltreey
    Author

    I literally have a fix for this, documented in this issue. This should be trivial to close.

  4. deiga commented on May 26, 2026

    @deiga
    Collaborator

    @deltreey many things are trivial to close, but it is not trivial to find time for everything, unfortunately.

    While we appreciate the effort you put into investigating this, you did not fully fill out the issue template and we're missing crucial information like the Debug-level logs. Could you extract your solution proposal into a comment, so that it's easier to read?

  5. deltreey commented on May 28, 2026

    @deltreey
    Author

    did that with a PR

  6. 3rwww1 commented on Sep 21, 2026

    @3rwww1

    Confirming on GitHub.com (not GHES) with provider v6.13.0, Terraform 1.16.3, running on Terraform Cloud remote workers. Same root cause as described above: the update path always sends allowed_actions, so enabled_repositories = "none" cannot be written.

    Repro 1 - none alone

    resource "github_actions_organization_permissions" "archive" {
      enabled_repositories = "none"
    }

    Plan is clean, apply fails. On GitHub.com the API answers 409 with an empty body instead of the 422 seen on GHES:

    Error: PUT https://api.github.com/orgs/<org>/actions/permissions: 409  []
    

    Repro 2 - the documented alternative also fails

    Trying to express "off" as selected with zero repositories crashes the provider:

    resource "github_actions_organization_permissions" "archive" {
      enabled_repositories = "selected"
      allowed_actions      = "local_only"
    
      enabled_repositories_config {
        repository_ids = []
      }
    }
    panic: interface conversion: interface {} is nil, not map[string]interface {}
    
    goroutine 82 [running]:
      github.com/integrations/terraform-provider-github/v6/github/resource_github_actions_organization_permissions.go:127
      github.com/integrations/terraform-provider-github/v6/github/resource_github_actions_organization_permissions.go:188
      github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:871
    

    Terraform reports it as Plugin did not respond. This is the second gap in the issue description (empty repository_ids), also covered by #3457.

    Workaround we use until #3457 ships

    1. Disable Actions out of band, with no other key in the body. Returns 204:

      gh api -X PUT /orgs/<org>/actions/permissions -f enabled_repositories=none
    2. Keep the resource in config with enabled_repositories = "none" and allowed_actions omitted. The GET response drops allowed_actions when Actions are off, the provider reads it back as "", and the plan is a no-op. Drift is still detected; re-applying it needs the hand PUT again.

    Reads are fine, only the transition PUT is broken. +1 for merging #3457, the fix is small and this blocks deny-by-default org baselines.

  7. removed
    Status: Triage
    on Oct 15, 2026
  8. self-assigned this
    on Oct 15, 2026
  9. added this to the v6.14.0 milestone on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type: Bugr/actions_organization_permissions

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions