Skip to content

Commit

Permalink
updating
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Arnold committed Feb 18, 2025
2 parents 7d4a8be + cff8f42 commit 09cc896
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 47 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/modtest-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "ModTest: dev"

on:
pull_request:
push:
branches:
- main

jobs:
modtest:
if : ${{ github.event_name }} == "pull_request"
uses: HappyPathway/centralized-actions/.github/workflows/modtest.yml@main
with:
workspace: dev
workspace_repo: github-repos
workspace_branch: main
repo_clone_type: https
mod_source: repo/github

github_server: ${{vars.GH_SERVER}}
github_org: ${{ github.repository_owner }}
branch: ${{ github.head_ref }}
terraform_version: ${{vars.TERRAFORM_VERSION}}
terraform_api_token_name: ${{ vars.TERRAFORM_API_TOKEN_NAME }}
terraform_api: ${{vars.TERRAFORM_API}}

secrets:
TFE_TOKEN: ${{ secrets.TFE_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
45 changes: 45 additions & 0 deletions .github/workflows/terraform-doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Terraform Doc"

on:
pull_request:

env:
GITHUB_OWNER: ${{ vars.GH_ORG }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
TF_WORKSPACE: happypathway
TFE_TOKEN: ${{ secrets.TFE_TOKEN }}

jobs:
tf-doc:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
id: checkout
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3.1.2
with:
terraform_version: ${{ vars.terraform_version }}
cli_config_credentials_token: ${{ secrets.TFE_TOKEN }}
cli_config_credentials_hostname: ${{ vars.terraform_api }}

- name: terraform init
run: terraform init -upgrade

- name: Render terraform docs inside the README.md and push changes back to PR branch
uses: terraform-docs/gh-actions@v1.2.0
with:
working-dir: .
output-file: README.md
output-method: inject
git-push: "true"

# terraform-docs/gh-actions@v1.0.0 modifies .git files with owner root:root, and the following steps fail with
# insufficient permission for adding an object to repository database .git/objects
# since the expected user is runner:docker. See https://github.com/terraform-docs/gh-actions/issues/90
- name: Fix .git owner
run: sudo chown runner:docker -R .git
49 changes: 11 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,43 +45,6 @@ module "repository" {
}
```

## Requirements

| Name | Version |
|------|---------|
| terraform | >= 1.0.0 |
| github | >= 5.0.0 |

## Providers

| Name | Version |
|------|---------|
| github | >= 5.0.0 |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| name | Repository name | `string` | n/a | yes |
| repo_org | GitHub organization name | `string` | n/a | yes |
| force_name | Force the repository name | `bool` | `false` | no |
| github_repo_description | Repository description | `string` | `""` | no |
| github_repo_topics | Repository topics | `list(string)` | `[]` | no |
| github_is_private | Private repository flag | `bool` | `true` | no |
| github_has_issues | Enable issues | `bool` | `true` | no |
| github_has_projects | Enable projects | `bool` | `false` | no |
| github_has_wiki | Enable wiki | `bool` | `false` | no |
| vulnerability_alerts | Enable vulnerability alerts | `bool` | `true` | no |
| gitignore_template | GitIgnore template name | `string` | `null` | no |
| managed_extra_files | Map of files to manage in the repository | `map(object({ content = string, overwrite = bool }))` | `{}` | no |

## Outputs

| Name | Description |
|------|-------------|
| github_repo | The complete GitHub repository object |
| repo_full_name | The full name of the repository (org/name) |

## Examples

### Basic Repository
Expand Down Expand Up @@ -154,4 +117,14 @@ terraform test

## License

MIT License - see [LICENSE](LICENSE) for details
MIT License - see [LICENSE](LICENSE) for details


[![Terraform Validation](https://github.com/HappyPathway/terraform-github-repo/actions/workflows/terraform.yaml/badge.svg)](https://github.com/HappyPathway/terraform-github-repo/actions/workflows/terraform.yaml)


[![Modtest Dev](https://github.com/HappyPathway/terraform-github-repo/actions/workflows/modtest-dev.yaml/badge.svg)](https://github.com/HappyPathway/terraform-github-repo/actions/workflows/modtest-dev.yaml)

<!-- BEGIN_TF_DOCS -->
{{ .Content }}
<!-- END_TF_DOCS -->
2 changes: 1 addition & 1 deletion github_branch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ locals {

# https://registry.terraform.io/providers/integrations/github/latest/docs/resources/branch_protection
resource "github_branch_protection" "main" {
count = var.enforce_prs ? 1 : 0
count = var.enforce_prs && !var.github_is_private ? 1 : 0
enforce_admins = var.github_enforce_admins_branch_protection
pattern = var.github_default_branch
# push_restrictions = var.github_push_restrictions
Expand Down
8 changes: 1 addition & 7 deletions github_repo.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ resource "github_repository" "repo" {
archived = var.archived
homepage_url = var.homepage_url
vulnerability_alerts = var.vulnerability_alerts
lifecycle {
ignore_changes = [
has_issues,
has_projects,
has_wiki
]
}

dynamic "template" {
# A bogus map for a conditional block
for_each = var.template_repo == null ? [] : ["*"]
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ variable "github_has_projects" {
default = true
}
variable "github_has_issues" {
default = false
default = true
}
variable "github_has_wiki" {
default = true
Expand Down

0 comments on commit 09cc896

Please sign in to comment.