File tree Expand file tree Collapse file tree 5 files changed +33
-23
lines changed Expand file tree Collapse file tree 5 files changed +33
-23
lines changed Original file line number Diff line number Diff line change 11LICENSE
22README.md
3+ .gitignore
4+ use_jwt.py
Original file line number Diff line number Diff line change 11MIT License
22
3- Copyright (c) 2024 Krishnadhas N K
3+ Copyright (c) 2024 Krishnadhas N K (githubofkrishnadhas)
44
55Permission is hereby granted, free of charge, to any person obtaining a copy
66of this software and associated documentation files (the "Software"), to deal
Original file line number Diff line number Diff line change @@ -10,4 +10,7 @@ inputs:
1010 description : " Github App private key"
1111runs :
1212 using : ' docker'
13- image : ' Dockerfile'
13+ image : ' Dockerfile'
14+ args :
15+ - ${{ inputs.github_app_id }}
16+ - ${{ inputs.github_app_private_key }}
Original file line number Diff line number Diff line change 77
88def create_jwt (pem_path , app_id ):
99 """
10- function to create JWT from Github app id and pvt key
10+ function to create JWT from GitHub app id and pvt key
1111 :param pem_path:
1212 :param app_id:
1313 :return:
@@ -35,25 +35,6 @@ def create_jwt(pem_path, app_id):
3535 print (f"JWT set as environment variable: JWT={ encoded_jwt } " )
3636 return encoded_jwt
3737
38- def make_github_api_request ():
39- url = " https://api.github.com/repositories"
40- headers = {
41- "Accept" : "application/vnd.github+json" ,
42- "Authorization" : f"Bearer { os .getenv ('GITHUB_JWT' )} " ,
43- "X-GitHub-Api-Version" : "2022-11-28"
44- }
45-
46- response = requests .get (url , headers = headers )
47- response_json = response .json ()
48-
49- if response .status_code == 200 :
50- print ("API request successful:" )
51- print (response_json )
52- else :
53- print (f"API request failed with status code { response .status_code } :" )
54- print (response_json )
55-
56-
5738def main ():
5839 """
5940 to test the code
@@ -69,6 +50,6 @@ def main():
6950
7051 # function call
7152 create_jwt (pem_path , app_id )
72- make_github_api_request ()
53+
7354if __name__ == "__main__" :
7455 main ()
Original file line number Diff line number Diff line change 1+ import os
2+ import requests
3+
4+
5+ def make_github_api_request ():
6+ url = " https://api.github.com/repositories"
7+ headers = {
8+ "Accept" : "application/vnd.github+json" ,
9+ "Authorization" : f"Bearer { os .getenv ('GITHUB_JWT' )} " ,
10+ "X-GitHub-Api-Version" : "2022-11-28"
11+ }
12+
13+ response = requests .get (url , headers = headers )
14+ response_json = response .json ()
15+
16+ if response .status_code == 200 :
17+ print ("API request successful:" )
18+ print (response_json )
19+ else :
20+ print (f"API request failed with status code { response .status_code } :" )
21+ print (response_json )
22+
23+ if __name__ == "__main__" :
24+ make_github_api_request ()
You can’t perform that action at this time.
0 commit comments