Check out a free preview of the full Enterprise DevOps & Cloud Infrastructure course

The "GitHub Automation Q&A" Lesson is part of the full, Enterprise DevOps & Cloud Infrastructure course featured in this preview video. Here's what you'd learn in this lesson:

Erik responds to questions about deleting/archiving repositories and creating global variable sets for tokens.

Preview
Close

Transcript from the "GitHub Automation Q&A" Lesson

[00:00:01]
>> Yeah, a couple of questions in the chat.
>> Yeah.
>> One is, what happens if we delete one repo from locals in our GitHub automation repo will Terraform delete this repo also?
>> Absolutely, 100% yes. We talked about this yesterday, actually just like in the off time, it will.

[00:00:21]
Yeah, Terraform is literal one to one, so if it's there, it'll be there, and if it's not, it won't be. My personal recommendation is to disable the ability to delete repos, right? Or make sure that you have scoped permissions or, basically follow an archive pattern, is good. GitHub does have archival options and so you could basically say don't delete anything, but make an archive option available to the repos in the config.

[00:00:48]
And then every repo you want you would just set archive to true. And this is actually what we do at GitHub, I'm sorry, what we do at Hippo. So if I was to go here at Hippo, actually here, I can show you like a 5,000 foot, I'll just go to our repos really quickly to show you.

[00:01:13]
So if I go to my Hippo, Hippo, Analytics-Inc, and then let's go to,

[00:01:17]
[MUSIC]

[00:01:20]
Here, search, Analytics-Inc. I wanna to go to github, Terraform-github, this is what our repo looks like. And you can see every file is a different set of repos that we're trying to solve problems with, right? And so, for example, if I was to go to ops repos, which is the ones that I normally manage, here's the layers of configurations that we do.

[00:01:48]
So, we have like default ops permissions for push and admin. We have specific providers because we have different accounts. We'll have branching schemes and enable branch protection. And these are lower-level logic, right, in the HCL. Topics, branching scheme, context, right, some of the things that we haven't even really talked about.

[00:02:09]
But again, if I go into this search and I search for the word archive. Yeah, there it is. We have an archived true, and so it won't delete it, but it'll at least make it so that the repository isn't managed anymore.
>> Is there a reason not to just create a global variable set applied to all or some workspaces with the tokens needed?

[00:02:33]
>> Yeah, if you wanted to. We're only going through it step by step for the course. So yeah, the layers of automation that you wanna do, it's totally up to you. A lot of the step-by-step is really to show you why we're doing what we're doing. Going forward you could, yeah, you could do that for sure, yeah.

[00:02:54]
>> And if you want to archive a repository, how could this fit in the current module setup with Terraform?
>> So if you wanted to archive a repository what you would do is you would go here. You would, I'm gonna be honest, I don't know if I've made it so you can archive repos with this particular module.

[00:03:14]
So you might, Yeah, so I haven't added archiving support with this. But if we go back to the GitHub, and this is where like, again, sometimes it's nice to use a provider, sometimes it's nice to use a module, sometimes that module might not give you what you want.

[00:03:32]
So in this case, I would actually go to GitHub, Terraform, look at the provider here, and then I would be like, okay, where's our repo, repository? There it is. And then scroll down until you see archived. Yeah, and so this value would then be what you would use on the resource and then you'd go to locals and then you'd add archived, true or false basically up here, right?

[00:04:07]
Archived, Bam, right? And then you can even do things like defaults where there is the ability to say like if it doesn't exist then just set it to not archive so that you only have archived in there, but that's basically how you would do it, yeah.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now