Skip to content

Commit 33331c9

Browse files
feat: update the action to uv and python 3.13
1 parent b15b511 commit 33331c9

8 files changed

Lines changed: 317 additions & 345 deletions

File tree

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Container image that runs your code
2-
FROM python:3.11-slim-bullseye
2+
FROM python:3.13-slim-bullseye
33

44
WORKDIR /app
55
# Copies your code file from your action repository to the filesystem path `/` of the container
66
COPY . /app/
77

88
# Install pipenv
9-
RUN chmod +x entrypoint.sh && apt-get update -y && pip install pipenv
9+
RUN chmod +x entrypoint.sh && apt-get update -y && curl -LsSf https://astral.sh/uv/install.sh | sh
1010

1111
# Code file to execute when the docker container starts up (`entrypoint.sh`)
1212
ENTRYPOINT ["/app/entrypoint.sh"]

Makefile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Default target
2+
.DEFAULT_GOAL := help
3+
4+
# Variables
5+
UV := uv
6+
7+
.PHONY: help install sync update tree add remove uninstall clean run lock
8+
9+
help: ## Show available commands
10+
@echo "Available commands:"
11+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
12+
awk 'BEGIN {FS = ":.*?## "}; {printf " %-15s %s\n", $$1, $$2}'
13+
14+
install: ## Install dependencies from pyproject.toml
15+
$(UV) sync
16+
17+
sync: ## Sync environment with lock file
18+
$(UV) sync
19+
20+
update: ## Update dependencies
21+
$(UV) lock --upgrade
22+
$(UV) sync
23+
24+
tree: ## Show dependency tree
25+
$(UV) tree
26+
27+
lock: ## Generate/update uv.lock
28+
$(UV) lock
29+
30+
add: ## Add a package (usage: make add package=requests)
31+
$(UV) add $(package)
32+
33+
remove: ## Remove a package (usage: make remove package=requests)
34+
$(UV) remove $(package)
35+
36+
uninstall: ## Alias for remove
37+
$(UV) remove $(package)
38+
39+
run: ## Run python app (usage: make run script=main.py)
40+
$(UV) run python $(script)
41+
42+
clean: ## Remove virtual environment and cache
43+
rm -rf .venv
44+
rm -rf .pytest_cache
45+
rm -rf __pycache__
46+
find . -type d -name "__pycache__" -exec rm -rf {} +

Pipfile

Lines changed: 0 additions & 16 deletions
This file was deleted.

Pipfile.lock

Lines changed: 0 additions & 323 deletions
This file was deleted.

entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ OWNER="$3"
1010
REPOSITORIES="$4"
1111

1212
# Build the command based on available parameters
13-
CMD="pipenv run python3 /app/generate_jwt.py --github_app_id \"$GITHUB_APP_ID\" --github_app_private_key \"$GITHUB_APP_PRIVATE_KEY\""
13+
CMD="uv run python3 /app/generate_jwt.py --github_app_id \"$GITHUB_APP_ID\" --github_app_private_key \"$GITHUB_APP_PRIVATE_KEY\""
1414

1515
if [ -n "$OWNER" ]; then
1616
CMD="$CMD --owner \"$OWNER\""

generate_jwt.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def create_jwt(private_key, app_id):
1414
:return: Encoded JWT.
1515
"""
1616
# Open PEM
17-
# with open(private_key, 'rb') as pem_file:
18-
# signing_key = jwk_from_pem(pem_file.read())
19-
signing_key = jwk_from_pem(private_key.encode('utf-8'))
17+
with open(private_key, 'rb') as pem_file:
18+
signing_key = jwk_from_pem(pem_file.read())
19+
# signing_key = jwk_from_pem(private_key.encode('utf-8'))
2020

2121

2222
payload = {
@@ -116,6 +116,7 @@ def generate_token_by_post_call(installation_id: int, jwt: str, repositories: st
116116
sys.exit(1)
117117

118118
token = response_json['token'] # setting the output token as token inside github output
119+
print(token)
119120
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
120121
fh.write(f'token={token}\n')
121122

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[project]
2+
name = "github-access-using-githubapp"
3+
version = "3.0.0"
4+
description = "An action to generate GitHub Installation Access Token using GitHub App's private key and AppId."
5+
requires-python = ">=3.13"
6+
authors = [
7+
{ name = "githubofkrishnadhas" }
8+
]
9+
10+
dependencies = [
11+
"requests >= 2.34.2",
12+
"jwt>= 1.4.0",
13+
"cryptography >=48.0.0",
14+
"python-dotenv >= 1.2.2"
15+
]

uv.lock

Lines changed: 249 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)