Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add github_actions_enterprise_permissions #2155

Merged
merged 3 commits into from Mar 8, 2024

Conversation

ErikElkins
Copy link
Contributor

Resolves part of #1199

This adds a new resource github_actions_enterprise_permissions to control GitHub Actions policy on an enterprise.

data "github_enterprise" "example-enterprise" {
  slug = "my-enterprise"
}

data "github_organization" "example-org" {
  name = "my-org"
}

resource "github_actions_enterprise_permissions" "test" {
  enterprise_id = data.github_enterprise.example-enterprise.slug
  allowed_actions = "selected"
  enabled_organizations = "selected"
  allowed_actions_config {
    github_owned_allowed = true 
    patterns_allowed     = ["actions/cache@*", "actions/checkout@*"]
    verified_allowed     = true
  }
  enabled_organizations_config {
    organization_ids = [data.github_organization.example-org.id]
  }
}

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

* Adding enterprise permissions resource

* Working version

* Adding docs

* Functioning tests
@kfcampbell
Copy link
Member

When running the new integration tests, I get the following error:

    resource_github_actions_enterprise_permissions_test.go:261: Step 1/1 error: Error running pre-apply refresh: exit status 1
        
        Error: Could not resolve to a Business with the URL slug of ''.
        
          with data.github_enterprise.enterprise,
          on terraform_plugin_test.tf line 3, in data "github_enterprise" "enterprise":
           3: 			data "github_enterprise" "enterprise" {
        

Can you reproduce this? Am I missing some kind of setup?

@ErikElkins
Copy link
Contributor Author

I missed the check on ENTERPRISE_SLUG and ENTERPRISE_ACCOUNT that the other enterprise dependent integration tests do here: https://github.com/integrations/terraform-provider-github/blob/main/github/resource_github_enterprise_organization_test.go#L91

Updated the PR.

@laughedelic
Copy link
Contributor

I don't know if there is a good reason for this, but between this PR and #2158 there is some naming inconsistency: github_enterprise_actions... vs. github_actions_enterprise.... I just noticed it when looking at the PRs list:
Screenshot 2024-03-03 at 18 05 02

@kfcampbell
Copy link
Member

@laughedelic good catch. I have a slight preference for github_enterprise_actions... since these are settings that only exist in enterprise, though I'd be happy to hear arguments either way.

@bradam12
Copy link
Contributor

bradam12 commented Mar 4, 2024

That was my thinking too, though there was only one example (github_enterprise_organization) to go off of. Either way works for me.

@ErikElkins
Copy link
Contributor Author

ErikElkins commented Mar 4, 2024

I named this after github_actions_organization_permissions. But if we think there will be more enterprise resources, github_enterprise... would be better.

Copy link
Member

@kfcampbell kfcampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have easy access to an enterprise for manual validation so please let me know if something isn't behaving right!

@kfcampbell kfcampbell merged commit 52e1853 into integrations:main Mar 8, 2024
3 checks passed
@bradam12
Copy link
Contributor

bradam12 commented Mar 13, 2024

Works in my enterprise.
Import doesn't work, as it always tries to force replacement, but applying without an import seems to be fine, since it's authoritative.

I think that's acceptable tbh.

$ terragrunt import github_enterprise_actions_permissions.enterprise enterprise

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

$ terragrunt plan
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # github_enterprise_actions_permissions.enterprise must be replaced
-/+ resource "github_enterprise_actions_permissions" "enterprise" {
      + enterprise_id         = "enterprise" # forces replacement
      ~ id                    = "enterprise" -> (known after apply)
        # (2 unchanged attributes hidden)

      ~ allowed_actions_config {
          ~ patterns_allowed     = [
              - "test/*",
                # (7 unchanged elements hidden)
            ]
            # (2 unchanged attributes hidden)
        }
    }

antnsn added a commit to CMCS-Norway/github-governance that referenced this pull request Mar 14, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github](https://registry.terraform.io/providers/integrations/github)
([source](https://togithub.com/integrations/terraform-provider-github))
| required_provider | minor | `6.0.0-beta` -> `6.1.0` |

---

### Release Notes

<details>
<summary>integrations/terraform-provider-github (github)</summary>

###
[`v6.1.0`](https://togithub.com/integrations/terraform-provider-github/releases/tag/v6.1.0)

[Compare
Source](https://togithub.com/integrations/terraform-provider-github/compare/v6.0.1...v6.1.0)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

##### What's Changed

- fix: validation rule for `results_per_page` of `github_repositories`
data source by [@&#8203;dschniepp](https://togithub.com/dschniepp) in
[integrations/terraform-provider-github#2185
- fix: Prevent loading of allowed actions if not configured by
[@&#8203;Danielku15](https://togithub.com/Danielku15) in
[integrations/terraform-provider-github#2186
- fix(data_source_github_rest_api): only allow for 404 on err by
[@&#8203;riezebosch](https://togithub.com/riezebosch) in
[integrations/terraform-provider-github#2154
- fix: error if autolink reference not found by
[@&#8203;bradam12](https://togithub.com/bradam12) in
[integrations/terraform-provider-github#2164
- feat: Add `github_actions_enterprise_permissions` by
[@&#8203;ErikElkins](https://togithub.com/ErikElkins) in
[integrations/terraform-provider-github#2155
- docs: configure release notes categories based on labels by
[@&#8203;laughedelic](https://togithub.com/laughedelic) in
[integrations/terraform-provider-github#2184

##### New Contributors

- [@&#8203;dschniepp](https://togithub.com/dschniepp) made their first
contribution in
[integrations/terraform-provider-github#2185
- [@&#8203;riezebosch](https://togithub.com/riezebosch) made their first
contribution in
[integrations/terraform-provider-github#2154
- [@&#8203;bradam12](https://togithub.com/bradam12) made their first
contribution in
[integrations/terraform-provider-github#2164
- [@&#8203;ErikElkins](https://togithub.com/ErikElkins) made their first
contribution in
[integrations/terraform-provider-github#2155
- [@&#8203;laughedelic](https://togithub.com/laughedelic) made their
first contribution in
[integrations/terraform-provider-github#2184

**Full Changelog**:
integrations/terraform-provider-github@v6.0.1...v6.1.0

###
[`v6.0.1`](https://togithub.com/integrations/terraform-provider-github/releases/tag/v6.0.1)

[Compare
Source](https://togithub.com/integrations/terraform-provider-github/compare/v6.0.0...v6.0.1)

#### What's Changed

- build(deps): bump github.com/golangci/golangci-lint from 1.56.1 to
1.56.2 by [@&#8203;dependabot](https://togithub.com/dependabot) in
[integrations/terraform-provider-github#2159
- build(deps): bump github.com/hashicorp/terraform-plugin-sdk/v2 from
2.31.0 to 2.32.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[integrations/terraform-provider-github#2160
- build(deps): bump github.com/hashicorp/terraform-plugin-sdk/v2 from
2.32.0 to 2.33.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[integrations/terraform-provider-github#2168
- Fix github_external_groups page title by
[@&#8203;tomasmota](https://togithub.com/tomasmota) in
[integrations/terraform-provider-github#2170
- docs: Update example usage to use version 6.0 by
[@&#8203;rnestler](https://togithub.com/rnestler) in
[integrations/terraform-provider-github#2169
- fix: Make allowed_actions_config optional by
[@&#8203;Danielku15](https://togithub.com/Danielku15) in
[integrations/terraform-provider-github#2114
- GitHub org ignore archived repos by
[@&#8203;felixlut](https://togithub.com/felixlut) in
[integrations/terraform-provider-github#1833
- build(deps): bump github.com/stretchr/testify from 1.8.4 to 1.9.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[integrations/terraform-provider-github#2177
- build(deps): bump golang.org/x/crypto from 0.19.0 to 0.21.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[integrations/terraform-provider-github#2180
- build(deps): bump actions/add-to-project from 0.5.0 to 0.6.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[integrations/terraform-provider-github#2175

#### New Contributors

- [@&#8203;tomasmota](https://togithub.com/tomasmota) made their first
contribution in
[integrations/terraform-provider-github#2170
- [@&#8203;rnestler](https://togithub.com/rnestler) made their first
contribution in
[integrations/terraform-provider-github#2169
- [@&#8203;Danielku15](https://togithub.com/Danielku15) made their first
contribution in
[integrations/terraform-provider-github#2114

**Full Changelog**:
integrations/terraform-provider-github@v6.0.0...v6.1.0

###
[`v6.0.0`](https://togithub.com/integrations/terraform-provider-github/releases/tag/v6.0.0)

[Compare
Source](https://togithub.com/integrations/terraform-provider-github/compare/v6.0.0-rc2...v6.0.0)

#### v6.0.0

Includes the following changes:

-
[#&#8203;1704](https://togithub.com/integrations/terraform-provider-github/issues/1704)
-
[#&#8203;2045](https://togithub.com/integrations/terraform-provider-github/issues/2045)
-
[#&#8203;1780](https://togithub.com/integrations/terraform-provider-github/issues/1780)
-
[#&#8203;1918](https://togithub.com/integrations/terraform-provider-github/issues/1918)
-
[#&#8203;2133](https://togithub.com/integrations/terraform-provider-github/issues/2133)

As we've upgraded Terraform SDK versions and are checking more errors,
you may see slightly different logging and error messages. Please use
the project's issues to report anything unexpected or buggy!

**Full Changelog**:
integrations/terraform-provider-github@v5.45.0...v6.0.0

###
[`v6.0.0-rc2`](https://togithub.com/integrations/terraform-provider-github/releases/tag/v6.0.0-rc2)

[Compare
Source](https://togithub.com/integrations/terraform-provider-github/compare/v6.0.0-rc1...v6.0.0-rc2)

#### What's Changed

- fix(resource_github_release): Handle missing release in read by
[@&#8203;arunsathiya](https://togithub.com/arunsathiya) in
[integrations/terraform-provider-github#2115
- docs: update commit_message arg desc for repository_file resource by
[@&#8203;manjinder-mckc](https://togithub.com/manjinder-mckc) in
[integrations/terraform-provider-github#2125
- Set group_id correctly in EMU mapping resource by
[@&#8203;kfcampbell](https://togithub.com/kfcampbell) in
[integrations/terraform-provider-github#2133

#### New Contributors

- [@&#8203;arunsathiya](https://togithub.com/arunsathiya) made their
first contribution in
[integrations/terraform-provider-github#2115

**Full Changelog**:
integrations/terraform-provider-github@v6.0.0-rc1...v6.0.0-rc2

###
[`v6.0.0-rc1`](https://togithub.com/integrations/terraform-provider-github/releases/tag/v6.0.0-rc1)

[Compare
Source](https://togithub.com/integrations/terraform-provider-github/compare/v6.0.0-beta...v6.0.0-rc1)

#### What's Changed

- fix: github_rest_api data source always returns header and body as
null by [@&#8203;srgustafson8](https://togithub.com/srgustafson8) in
[integrations/terraform-provider-github#2110
- build(deps): bump peter-evans/create-or-update-comment from 3 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[integrations/terraform-provider-github#2121
- build(deps): bump github.com/google/uuid from 1.5.0 to 1.6.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[integrations/terraform-provider-github#2120
- Add support for packages IP ranges in github_ip_ranges by
[@&#8203;Nmishin](https://togithub.com/Nmishin) in
[integrations/terraform-provider-github#1958
- Fix restrict pushes on github_branch_protection. Fix branch protection
tests by [@&#8203;georgekaz](https://togithub.com/georgekaz) in
[integrations/terraform-provider-github#2045

#### New Contributors

- [@&#8203;georgekaz](https://togithub.com/georgekaz) made their first
contribution in
[integrations/terraform-provider-github#2045

**Full Changelog**:
integrations/terraform-provider-github@v6.0.0-beta...v6.0.0-rc1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/CMCS-Norway/github-governance).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNDUuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI0NS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
kireque pushed a commit to kireque/home-ops that referenced this pull request Mar 22, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github](https://registry.terraform.io/providers/integrations/github)
([source](https://togithub.com/integrations/terraform-provider-github))
| required_provider | minor | `6.0.1` -> `6.2.0` |

---

### Release Notes

<details>
<summary>integrations/terraform-provider-github (github)</summary>

###
[`v6.2.0`](https://togithub.com/integrations/terraform-provider-github/releases/tag/v6.2.0)

[Compare
Source](https://togithub.com/integrations/terraform-provider-github/compare/v6.1.0...v6.2.0)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

##### Features

- feat: add `github_enterprise_actions_runner_group` by
[@&#8203;bradam12](https://togithub.com/bradam12) in
[integrations/terraform-provider-github#2158
- Feat: Fixes abandoned PR
[#&#8203;2017](https://togithub.com/integrations/terraform-provider-github/issues/2017):
Add support for the require_last_push_approval flag in
github_branch_protection_v3 by
[@&#8203;georgekaz](https://togithub.com/georgekaz) in
[integrations/terraform-provider-github#2199

##### Bugfixes

- fix(data_source_github_rest_api): just read body and convert bytes
into string by [@&#8203;riezebosch](https://togithub.com/riezebosch) in
[integrations/terraform-provider-github#2152

##### 🛠️ Maintenance

- build(deps): bump golang.org/x/oauth2 from 0.17.0 to 0.18.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[integrations/terraform-provider-github#2189
- build(deps): bump google.golang.org/protobuf from 1.32.0 to 1.33.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[integrations/terraform-provider-github#2194

**Full Changelog**:
integrations/terraform-provider-github@v6.1.0...v6.2.0

###
[`v6.1.0`](https://togithub.com/integrations/terraform-provider-github/releases/tag/v6.1.0)

[Compare
Source](https://togithub.com/integrations/terraform-provider-github/compare/v6.0.1...v6.1.0)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

- fix: validation rule for `results_per_page` of `github_repositories`
data source by [@&#8203;dschniepp](https://togithub.com/dschniepp) in
[integrations/terraform-provider-github#2185
- fix: Prevent loading of allowed actions if not configured by
[@&#8203;Danielku15](https://togithub.com/Danielku15) in
[integrations/terraform-provider-github#2186
- fix(data_source_github_rest_api): only allow for 404 on err by
[@&#8203;riezebosch](https://togithub.com/riezebosch) in
[integrations/terraform-provider-github#2154
- fix: error if autolink reference not found by
[@&#8203;bradam12](https://togithub.com/bradam12) in
[integrations/terraform-provider-github#2164
- feat: Add `github_actions_enterprise_permissions` by
[@&#8203;ErikElkins](https://togithub.com/ErikElkins) in
[integrations/terraform-provider-github#2155
- docs: configure release notes categories based on labels by
[@&#8203;laughedelic](https://togithub.com/laughedelic) in
[integrations/terraform-provider-github#2184

#### New Contributors

- [@&#8203;dschniepp](https://togithub.com/dschniepp) made their first
contribution in
[integrations/terraform-provider-github#2185
- [@&#8203;riezebosch](https://togithub.com/riezebosch) made their first
contribution in
[integrations/terraform-provider-github#2154
- [@&#8203;bradam12](https://togithub.com/bradam12) made their first
contribution in
[integrations/terraform-provider-github#2164
- [@&#8203;ErikElkins](https://togithub.com/ErikElkins) made their first
contribution in
[integrations/terraform-provider-github#2155
- [@&#8203;laughedelic](https://togithub.com/laughedelic) made their
first contribution in
[integrations/terraform-provider-github#2184

**Full Changelog**:
integrations/terraform-provider-github@v6.0.1...v6.1.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNDAuMSIsInVwZGF0ZWRJblZlciI6IjM3LjI1Ny4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: kireque-bot[bot] <143391978+kireque-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants