Skip to content

Commit 3759afd

Browse files
committed
feat(repo): Add tf code for adding PATs to secrets
1 parent 2080e31 commit 3759afd

File tree

6 files changed

+65
-2
lines changed

6 files changed

+65
-2
lines changed

.github/workflows/sync-nuget.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ jobs:
5454
- name: Run NuGet sync script
5555
run: python scripts/sync_nuget.py
5656
env:
57-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
GITHUB_TOKEN: ${{ secrets.GH_NUGET_TOKEN }}
5858
# Add any other environment variables needed by your script

scripts/sync_nuget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class NuGetSyncer:
77
def __init__(self):
88
self.NUGET_FEED_URL = "https://pkgs.dev.azure.com/Keyfactor/_packaging/KeyfactorPackages/nuget/v3/index.json"
99
self.GITHUB_NUGET_URL = "https://nuget.pkg.github.com/keyfactor/index.json"
10-
self.GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
10+
self.GITHUB_TOKEN = os.getenv("GH_NUGET_TOKEN", os.getenv("GITHUB_TOKEN"))
1111
self.TMP_DIR = "../nupkgs"
1212
self.PACKAGES_YML = "../packages.yml"
1313
self.allowed_packages = self.load_allowed_packages()

terraform/repo-config/main.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Repository reference
2+
data "github_repository" "nuget_repo" {
3+
full_name = "Keyfactor/public-nuget-packages"
4+
}
5+
6+
// Create the Azure DevOps PAT secret for NuGet package downloads
7+
resource "github_actions_secret" "az_devops_pat" {
8+
repository = data.github_repository.nuget_repo.name
9+
secret_name = "AZ_DEVOPS_PAT"
10+
plaintext_value = var.az_devops_pat
11+
}
12+
13+
// Create the GitHub PAT secret for GitHub Package uploads
14+
// Note: This is separate from the built-in GITHUB_TOKEN
15+
resource "github_actions_secret" "github_pat" {
16+
repository = data.github_repository.nuget_repo.name
17+
secret_name = "GH_NUGET_TOKEN"
18+
plaintext_value = var.repo_github_pat
19+
}
20+

terraform/repo-config/outputs.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Outputs
2+
output "repository_name" {
3+
value = data.github_repository.nuget_repo.name
4+
}
5+
6+
output "secrets_configured" {
7+
value = [
8+
github_actions_secret.az_devops_pat.secret_name,
9+
github_actions_secret.github_pat.secret_name
10+
]
11+
}

terraform/repo-config/providers.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// GitHub provider configuration
2+
terraform {
3+
required_providers {
4+
github = {
5+
source = "integrations/github"
6+
version = "~> 5.0"
7+
}
8+
}
9+
}
10+
11+
// Configure the GitHub Provider
12+
provider "github" {
13+
owner = "Keyfactor"
14+
}

terraform/repo-config/variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Variables
2+
# variable "github_token" {
3+
# description = "GitHub personal access token with repo permissions"
4+
# type = string
5+
# sensitive = true
6+
# }
7+
8+
variable "az_devops_pat" {
9+
description = "Azure DevOps personal access token with package read permissions"
10+
type = string
11+
sensitive = true
12+
}
13+
14+
variable "repo_github_pat" {
15+
description = "GitHub personal access token with package write permissions"
16+
type = string
17+
sensitive = true
18+
}

0 commit comments

Comments
 (0)