@@ -22,11 +22,12 @@ def create_or_update_organization_secret_github(organization: str, secret_name:
2222 The token must have the following permission set: organization_secrets:write
2323 """
2424 encrypted_secret = os .getenv ('ENCRYPTED_SECRET' )
25+ repo_name = os .getenv ('REPOSITORY_NAME' )
2526 if not encrypted_secret :
2627 print ("ENCRYPTED_SECRET environment variable is not set or is empty." )
2728 print (f'encrypted sec is: { encrypted_secret } ' )
2829 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 } "
3031
3132 headers = {
3233 "Accept" : "application/vnd.github+json" ,
@@ -36,13 +37,13 @@ def create_or_update_organization_secret_github(organization: str, secret_name:
3637 data = {
3738 "encrypted_value" : encrypted_secret ,
3839 "visibility" : "all" ,
39- "key_id" : os .getenv ('PUBLIC_KEY_ID ' )
40+ "key_id" : os .getenv ('REPOSITORY_PUBLIC_KEY_ID ' )
4041 }
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 } " )
4445 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 } " )
4647
4748
4849def main ():
0 commit comments