get status from github api

This commit is contained in:
Bryan Gerlach
2026-03-10 23:58:13 -05:00
parent d186b7dd02
commit 8adecbfc1d
3 changed files with 25 additions and 3 deletions

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0.3 on 2026-03-11 04:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rdgenerator', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='githubrun',
name='github_run_id',
field=models.BigIntegerField(blank=True, null=True),
),
]

View File

@@ -5,4 +5,3 @@ class GithubRun(models.Model):
uuid = models.CharField(verbose_name="uuid", max_length=100) uuid = models.CharField(verbose_name="uuid", max_length=100)
status = models.CharField(verbose_name="status", max_length=100) status = models.CharField(verbose_name="status", max_length=100)
github_run_id = models.BigIntegerField(null=True, blank=True) github_run_id = models.BigIntegerField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)

View File

@@ -348,8 +348,6 @@ def check_for_file(request):
headers = {"Authorization": f"Bearer {_settings.GHBEARER}"} headers = {"Authorization": f"Bearer {_settings.GHBEARER}"}
api_url = f"https://api.github.com/repos/{_settings.GHUSER}/{_settings.REPONAME}/actions/runs/{gh_run.github_run_id}" api_url = f"https://api.github.com/repos/{_settings.GHUSER}/{_settings.REPONAME}/actions/runs/{gh_run.github_run_id}"
github_log_url = f"https://github.com/{_settings.GHUSER}/{_settings.REPONAME}/actions/runs/{gh_run.github_run_id}" github_log_url = f"https://github.com/{_settings.GHUSER}/{_settings.REPONAME}/actions/runs/{gh_run.github_run_id}"
timeout_limit = gh_run.created_at + timedelta(hours=2)
try: try:
gh_response = requests.get(api_url, headers=headers) gh_response = requests.get(api_url, headers=headers)
@@ -396,6 +394,13 @@ def get_png(request):
return response return response
def create_github_run(myuuid):
new_github_run = GithubRun(
uuid=myuuid,
status="Starting generator...please wait"
)
new_github_run.save()
def update_github_run(request): def update_github_run(request):
data = json.loads(request.body) data = json.loads(request.body)
myuuid = data.get('uuid') myuuid = data.get('uuid')