Ajouter gitea/add-secret.ps1
This commit is contained in:
47
gitea/add-secret.ps1
Normal file
47
gitea/add-secret.ps1
Normal file
@@ -0,0 +1,47 @@
|
||||
cls
|
||||
|
||||
$repos = @("Tips-Of-Mine/terraform-aws-iam-account", "Tips-Of-Mine/terraform-aws-iam-assumable-role-with-oidc", "Tips-Of-Mine/terraform-aws-iam-assumable-role-with-saml", "Tips-Of-Mine/terraform-aws-iam-assumable-role", "Tips-Of-Mine/terraform-aws-iam-assumable-roles-with-saml", "Tips-Of-Mine/terraform-aws-iam-assumable-roles", "Tips-Of-Mine/terraform-aws-iam-group-with-assumable-roles-policy", "Tips-Of-Mine/terraform-aws-iam-group-with-policies", "Tips-Of-Mine/terraform-aws-iam-policy", "Tips-Of-Mine/terraform-aws-iam-user")
|
||||
|
||||
$secrets = @("vault_url","vault_token","aws_access_key_id","aws_secret_access_key")
|
||||
|
||||
$token = "9999999999999999999999999999999999999999"
|
||||
|
||||
$headers = @{
|
||||
"accept" = "application/json"
|
||||
"Content-Type" = "application/json"
|
||||
}
|
||||
|
||||
Foreach ($repo in $repos) {
|
||||
|
||||
$response= $null
|
||||
|
||||
Foreach ($secret in $secrets) {
|
||||
|
||||
$apiUrl = "https://gitea.tips-of-mine.com/api/v1/repos/$repo/actions/secrets/$secret"+"?token=$token"
|
||||
|
||||
If ($secret -eq "vault_url") {
|
||||
$data = "https://xxxxxxxxxxxxxxxxxxx"
|
||||
}
|
||||
ElseIf ($secret -eq "vault_token") {
|
||||
$data = "hvs.000000000000000000000000"
|
||||
}
|
||||
ElseIf ($secret -eq "aws_access_key_id") {
|
||||
$data = "00000000000000000000"
|
||||
}
|
||||
ElseIf ($secret -eq "aws_secret_access_key") {
|
||||
$data = "f/00000000000000000000000000000000000000"
|
||||
}
|
||||
Else {
|
||||
$data = ""
|
||||
}
|
||||
|
||||
$body = @{
|
||||
"data" = $data
|
||||
"description" = "$secret"
|
||||
} | ConvertTo-Json -Depth 10
|
||||
|
||||
$response = Invoke-RestMethod -Uri $apiUrl -Method PUT -Headers $headers -Body $body
|
||||
|
||||
$response
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user