Skip to content

Git repository for a software project with optional GitHub mirror (GitLab) (Mirror of https://gitlab.com/sr2c/terraform-gitlab-software-project)

Notifications You must be signed in to change notification settings

sr2c/terraform-gitlab-software-project

Repository files navigation

terraform-gitlab-software-project

pipeline status latest release gitlab stars gitlab forks

SR2 Communications Limited

README Header

GitLab project for a software project with optional GitHub mirror.


Usage

terraform {
  required_providers {
    gitlab = {
      source = "gitlabhq/gitlab"
    }
    github = {
      source = "integrations/github"
    }
  }
}

provider "gitlab" {
  token = local.gitlab_token
}
  
provider "github" {
  token = local.github_token
  owner = local.github_organization_name
}

locals {
  gitlab_token             = ""        # Generate this using the instructions below
  gitlab_group_id          = 11925634  # Change this to your organization's GitLab group ID
  github_organization_name = "sr2c"    # Change this to your organization's name
  github_token             = ""        # Generate this using the instructions below
}

module "projects" {
  source        = "sr2c/software-project/gitlab"
  gitlab_group  = local.gitlab_group_id
  name          = "terraform-null-example"
  description   = "An example Terraform module (null provider)"
  github_mirror = true
  github_user   = "ExampleMirrorBot"
  github_token  = local.github_token
}

Generating the GitLab token

To configure GitLab, you will need an access token. GitLab has a variety of scoped access tokens, including personal and group access tokens. Project-level access tokens cannot be used with this module. Create the type of token that is suitable according to your threat model.

Add a name so that you will be reminded of the purpose of this token when you go to look at it later. Your access token will need the “api” scope. The expiry can be set according to your threat model. GitLab will send an email warning to token owners 7 days before expiry allowing you to generate a new token and update your configuration.

Generating the GitHub token

To configure GitHub, you will need a “personal access token”. It is not possible to restrict a token to specific repositories, so it is best to create a machine user and then invite that user to only the repositories that should be accessed to limit the impact of a token disclosure.

To create a token, visit the New personal access token page of the GitHub settings. Add a note so that you will be reminded of the purpose of this token when you go to look at it later. Your access token will need the “repo” OAuth scope.

The expiry can be set according to your threat model. GitHub will send an email warning before the token expires allowing you to generate a new token and update your configuration.

Requirements

Name Version
terraform >= 1.0.11
github >= 5.15.0
gitlab >= 3.19.0
null >= 3.2

Providers

Name Version
github >= 5.15.0
gitlab >= 3.19.0
null >= 3.2

Modules

No modules.

Resources

Name Type
github_repository.this resource
gitlab_project.this resource
gitlab_project_mirror.this resource
null_resource.trigger_mirror_push resource

Inputs

Name Description Type Default Required
archived Whether the project is archived bool false no
avatar_path Filesystem path to the project avatar string null no
description The project description. string n/a yes
enabled Set to false to prevent the module from creating any resources. bool true no
github_mirror Create a mirror of this project on GitHub. bool false no
github_token The GitHub access token to use for mirroring (required if github_mirror is true). string "" no
github_user The GitHub username to use for mirroring (required if github_mirror is true). string "" no
gitlab_group The ID of the GitLab group in which to create the project. If this is not specified, it will be created in the personal namespace of the authenticated user. number null no
gitlab_token The GitLab access token to use to trigger an initial mirror push. No initial push will happen if null. string null no
issues_template The template to use for new issues. string null no
merge_requests_template The template to use for new merge requests. string null no
name The project name. string n/a yes
shared_runners Enable shared runners on the GitLab repository. bool true no
visibility The visibility of the project. Allowed values are "public" and "private". This will apply also to the GitHub mirror if specified to be created. string "public" no

Outputs

Name Description
github_repository_git_url The URL to clone from the GitHub mirror using the git protocol, if created.
github_repository_web_url The web URL for the GitHub mirror, if created.
gitlab_project_id The ID of the GitLab project.
gitlab_project_ssh_url The SSH URL to clone/push this GitLab project.
gitlab_project_web_url The web URL for the GitLab project.

Makefile Targets

Available targets:

  help                                Help screen
  help/all                            Display help for all targets
  help/short                          This help short screen
  lint                                Lint terraform code

Share the Love

Like this project? Please give it a ★ on our GitLab! (it helps us a lot)

References

For additional context, refer to some of these links.

Help

Got a question? We got answers.

File a GitLab issue, send us an email or join our IRC.

README Commercial Support

IRC

IRC badge

Join our public chat on IRC. If you don't have an IRC client already, you can get started with the web client. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build on our open source code.

Contributing

Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Developing

If you are interested in being a contributor and want to get involved in developing this project or help out with our other projects, we would love to hear from you! Shoot us an email.

In general, MRs are welcome. We follow the typical "fork-and-pull" Git workflow:

  1. Fork the repo on GitLab
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Push your work back up to your fork
  5. Submit a Merge Request so that we can review your changes

NOTE: Be sure to merge the latest changes from "upstream" before making a pull request!

We have adopted the Conventional Commits specification for the formatting of commit messages.

Copyright

Copyright © 2021-2024 SR2 Communications Limited

Trademarks

All other trademarks referenced herein are the property of their respective owners.

About

This project is maintained by SR2 Communications Limited.

SR2 Communications Limited

We're a DevOps services company based in Aberdeen, Scotland. We specialise in solutions for online freedom, digital sovereignty and anti-censorship.

We offer paid support on all of our projects.

Check out our other projects, or hire us to get support with using our projects.

Contributors

irl
irl

About

Git repository for a software project with optional GitHub mirror (GitLab) (Mirror of https://gitlab.com/sr2c/terraform-gitlab-software-project)

Resources

Stars

Watchers

Forks

Packages

No packages published