Skip to content

Commit

Permalink
Github: add branch protection rule
Browse files Browse the repository at this point in the history
  • Loading branch information
drichelson committed May 31, 2024
1 parent 3a686bd commit b385c89
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/main/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ provider "github" {
}

module "dorkly-flags-example" {
source = "git::git@github.com:dorklyorg/terraform-aws-dorkly-flags.git//?ref=v0.0.6"
source = "git::git@github.com:dorklyorg/terraform-aws-dorkly-flags.git//?ref=v0.0.7"
project_name = "example"

# for demo purposes only. You should probably set this to true.
Expand Down
2 changes: 1 addition & 1 deletion examples/test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module "dorkly-flags-example" {
project_name = "example-test"
ld_relay_log_level = "debug"

# github_repo_private = false # for demo purposes set this to true
github_repo_private = false
}

output "ld_sdk_endpoint" {
Expand Down
21 changes: 17 additions & 4 deletions github.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,23 @@ locals {
}

resource "github_repository" "dorkly_repo" {
name = "dorkly-flags-${var.project_name}"
description = var.github_repo_description
visibility = var.github_repo_private ? "private" : "public"
auto_init = true
name = "dorkly-flags-${var.project_name}"
description = var.github_repo_description
visibility = var.github_repo_private ? "private" : "public"
auto_init = true
has_issues = false
delete_branch_on_merge = true
}

resource "github_branch_protection" "main_branch_protection" {
repository_id = github_repository.dorkly_repo.id
pattern = "main"
required_linear_history = true

enforce_admins = false
required_pull_request_reviews {
dismiss_stale_reviews = true
}
}

resource "github_actions_variable" "aws_region" {
Expand Down
25 changes: 25 additions & 0 deletions githubFiles/.github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Pull Request

on:
pull_request:
branches: [main]
types: [opened, reopened, synchronize]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5 # see https://github.com/actions/setup-go/tags for latest version
with:
go-version: '1.22.2'

- name: Build go binary
run: go install github.com/dorklyorg/dorkly/cmd/validator@${{ inputs.dorkly-version || vars.DORKLY_VERSION }}

- name: run validator
run: validator
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ variable "github_repo_private" {
# More optional vars that you should probably only change if you know what you're doing:
variable "dorkly_docker_image_tag" {
type = string
default = "0.0.4"
default = "0.0.4" # https://hub.docker.com/r/drichelson/dorkly/tags
description = "The docker image tag to use for the dorkly backend sservice. See https://hub.docker.com/r/drichelson/dorkly/tags for available tags."
}

variable "dorkly_version" {
type = string
default = "v0.0.7"
default = "v0.0.9" # latest releases: https://github.com/dorklyorg/dorkly/releases
description = "The version of the dorkly binary to use. This can be any valid git tag, branch, or commit hash from https://github.com/dorklyorg/dorkly"
}

0 comments on commit b385c89

Please sign in to comment.