@@ -22,11 +22,12 @@ def create_or_update_organization_secret_github(organization: str, secret_name:
22
22
The token must have the following permission set: organization_secrets:write
23
23
"""
24
24
encrypted_secret = os .getenv ('ENCRYPTED_SECRET' )
25
+ repo_name = os .getenv ('REPOSITORY_NAME' )
25
26
if not encrypted_secret :
26
27
print ("ENCRYPTED_SECRET environment variable is not set or is empty." )
27
28
print (f'encrypted sec is: { encrypted_secret } ' )
28
29
ist_now_formatted = current_ist_time ()
29
- github_org_secret_endpoint = f"https://api.github.com/orgs /{ organization } /actions/secrets/{ secret_name } "
30
+ github_repo_secret_endpoint = f"https://api.github.com/repos /{ organization } / { repo_name } /actions/secrets/{ secret_name } "
30
31
31
32
headers = {
32
33
"Accept" : "application/vnd.github+json" ,
@@ -36,13 +37,13 @@ def create_or_update_organization_secret_github(organization: str, secret_name:
36
37
data = {
37
38
"encrypted_value" : encrypted_secret ,
38
39
"visibility" : "all" ,
39
- "key_id" : os .getenv ('PUBLIC_KEY_ID ' )
40
+ "key_id" : os .getenv ('REPOSITORY_PUBLIC_KEY_ID ' )
40
41
}
41
- response = requests .put (github_org_secret_endpoint , headers = headers , json = data )
42
- if response .status_code == ' 201' :
43
- print (f"Secret { secret_name } created { organization } at { ist_now_formatted } " )
42
+ response = requests .put (github_repo_secret_endpoint , headers = headers , json = data )
43
+ if response .status_code == 201 :
44
+ print (f"Secret { secret_name } created { repo_name } at { ist_now_formatted } " )
44
45
else :
45
- print (f"Secret { secret_name } updated on { organization } at { ist_now_formatted } " )
46
+ print (f"Secret { secret_name } updated on { repo_name } at { ist_now_formatted } " )
46
47
47
48
48
49
def main ():
0 commit comments