Skip to content

Commit cde494a

Browse files
DEVOPS-46 updated the action
1 parent 7ef2dde commit cde494a

File tree

5 files changed

+33
-23
lines changed

5 files changed

+33
-23
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
LICENSE
22
README.md
3+
.gitignore
4+
use_jwt.py

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Krishnadhas N K
3+
Copyright (c) 2024 Krishnadhas N K (githubofkrishnadhas)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ inputs:
1010
description: "Github App private key"
1111
runs:
1212
using: 'docker'
13-
image: 'Dockerfile'
13+
image: 'Dockerfile'
14+
args:
15+
- ${{ inputs.github_app_id }}
16+
- ${{ inputs.github_app_private_key }}

generate_jwt.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
def 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-
5738
def 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+
7354
if __name__ == "__main__":
7455
main()

use_jwt.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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()

0 commit comments

Comments
 (0)