show link even on failure

This commit is contained in:
Bryan Gerlach
2026-03-12 11:30:55 -05:00
parent 6d9c13affa
commit 5c904d0e02
2 changed files with 168 additions and 69 deletions

View File

@@ -1,80 +1,156 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html>
<head> <head>
<meta charset="UTF-8"> <title id="pageTitle">Build Failure</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Generation Failed</title>
<style> <style>
body { body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
display: flex; display: flex;
flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
height: 100vh; height: 100vh;
margin: 0; margin: 0;
background-color: #f9f9f9;
color: #333;
}
.container {
text-align: center; text-align: center;
padding: 2rem; background: linear-gradient(135deg, #ffcfcf 0%, #e2c3c3 100%);
}
.platform-logo {
width: 150px;
height: 150px;
margin-bottom: 30px;
display: none;
filter: drop-shadow(0 10px 15px rgba(0,0,0,0.2));
transition: transform 0.3s ease;
}
.error-container {
background: white; background: white;
border-radius: 12px;
padding: 30px;
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
max-width: 500px;
width: 90%;
}
.error-header {
color: #c0392b;
font-weight: 700;
margin-bottom: 10px;
font-size: 1.5em;
}
.warning-box {
background-color: #fff3cd;
border: 1px solid #ffeeba;
color: #856404;
padding: 15px;
border-radius: 8px; border-radius: 8px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1); margin-bottom: 20px;
max-width: 400px; font-size: 0.9em;
text-align: left;
} }
.icon { .download-section {
font-size: 48px; background: #f8f9fa;
color: #d9534f; padding: 15px;
margin-bottom: 1rem; border-radius: 10px;
border: 1px dashed #ccc;
} }
h1 { .download-link {
margin: 0 0 1rem 0; display: block;
font-size: 24px; margin: 10px 0;
} padding: 12px;
p { background-color: #34495e;
color: #666;
line-height: 1.5;
margin-bottom: 2rem;
}
.btn {
display: inline-block;
padding: 10px 20px;
background-color: #007bff;
color: white; color: white;
text-decoration: none; text-decoration: none;
border-radius: 4px; border-radius: 5px;
font-weight: bold; transition: opacity 0.3s ease;
transition: background 0.2s;
} }
.btn:hover { .download-link:hover {
background-color: #0056b3; opacity: 0.8;
}
.log-link {
display: inline-block;
margin-top: 15px;
color: #3498db;
text-decoration: none;
font-size: 0.85em;
}
.platform-note {
color: #666;
font-size: 0.85em;
margin-top: 15px;
} }
</style> </style>
</head> </head>
<body> <body>
<svg id="windowsLogo" class="platform-logo" viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg">
<rect width="256" height="256" rx="50" ry="50" fill="#0078D7"/>
<text x="128" y="160" font-family="Arial" font-size="50" font-weight="bold" text-anchor="middle" fill="white">Win</text>
</svg>
<div class="error-container">
<h2 class="error-header">Workflow Interrupted</h2>
<div class="container"> <div class="warning-box">
<div class="icon"></div> <strong>Warning:</strong> The build process did not complete successfully. Some files may be missing. You can attempt to download the available files below.
<h1>Generation Failed</h1>
<p>Something went wrong during the GitHub Action process. This could be due to a timeout, a script error, or a server issue.</p>
<a href="/" class="btn">Return to Form</a>
</div>
<div class="container">
<div class="icon"></div>
<h1>Generation Failed</h1>
<p>Something went wrong during the process.</p>
<div style="background: #f1f1f1; padding: 15px; border-radius: 5px; margin-bottom: 20px;">
<a href="{{ log_url }}" target="_blank" style="color: #d9534f; font-weight: bold;">
Check GitHub Logs for Errors
</a>
</div> </div>
<a href="/" class="btn">Return to Form</a> <div class="download-section">
{% if platform == 'windows' %}
<a href='/download?filename={{filename}}.exe&uuid={{uuid}}' class="download-link">Download {{filename}}.exe</a>
<a href='/download?filename={{filename}}.msi&uuid={{uuid}}' class="download-link">Download {{filename}}.msi</a>
{% elif platform == 'windows-x86' %}
<a href='/download?filename={{filename}}.exe&uuid={{uuid}}' class="download-link">Download {{filename}}.exe</a>
{% elif platform == 'linux' %}
<a href='/download?filename={{filename}}-x86_64.deb&uuid={{uuid}}' class="download-link">Download {{filename}}-x86_64.deb</a>
<a href='/download?filename={{filename}}-x86_64.rpm&uuid={{uuid}}' class="download-link">Download {{filename}}-x86_64.rpm</a>
<a href='/download?filename={{filename}}-suse-x86_64.rpm&uuid={{uuid}}' class="download-link">Download {{filename}}-suse-x86_64.rpm</a>
<a href='/download?filename={{filename}}-x86_64.pkg.tar.zst&uuid={{uuid}}' class="download-link">Download {{filename}}-x86_64.pkg.tar.zst</a>
<a href='/download?filename={{filename}}-aarch64.deb&uuid={{uuid}}' class="download-link">Download {{filename}}-aarch64.deb</a>
<a href='/download?filename={{filename}}-aarch64.rpm&uuid={{uuid}}' class="download-link">Download {{filename}}-aarch64.rpm</a>
<a href='/download?filename={{filename}}-suse-aarch64.rpm&uuid={{uuid}}' class="download-link">Download {{filename}}-suse-aarch64.rpm</a>
<a href='/download?filename={{filename}}-aarch64.pkg.tar.zst&uuid={{uuid}}' class="download-link">Download {{filename}}-aarch64.pkg.tar.zst</a>
<a href='/download?filename={{filename}}-x86_64.AppImage&uuid={{uuid}}' class="download-link">Download {{filename}}-x86_64.AppImage</a>
<a href='/download?filename={{filename}}-aarch64.AppImage&uuid={{uuid}}' class="download-link">Download {{filename}}-aarch64.AppImage</a>
<a href='/download?filename={{filename}}-x86_64.flatpak&uuid={{uuid}}' class="download-link">Download {{filename}}-x86_64.flatpak</a>
<a href='/download?filename={{filename}}-aarch64.flatpak&uuid={{uuid}}' class="download-link">Download {{filename}}-aarch64.flatpak</a>
{% elif platform == 'android' %}
<a href='/download?filename={{filename}}-aarch64.apk&uuid={{uuid}}' class="download-link">Download {{filename}}-aarch64.apk</a>
<a href='/download?filename={{filename}}-x86_64.apk&uuid={{uuid}}' class="download-link">Download {{filename}}-x86_64.apk</a>
<a href='/download?filename={{filename}}-armv7.apk&uuid={{uuid}}' class="download-link">Download {{filename}}-armv7.apk</a>
{% elif platform == 'macos' %}
<a href='/download?filename={{filename}}-x86_64.dmg&uuid={{uuid}}' class="download-link">Download {{filename}}-x86_64.dmg</a>
<a href='/download?filename={{filename}}-aarch64.dmg&uuid={{uuid}}' class="download-link">Download {{filename}}-aarch64.dmg</a>
{% else %}
<p>Error: No file generated</p>
{% endif %}
</div>
<a href="{{ log_url }}" target="_blank" class="log-link">Check GitHub Logs for error details ↗</a>
<div id="platformNote" class="platform-note"></div>
<hr style="border: 0; border-top: 1px solid #eee; margin: 20px 0;">
<a href="/" style="font-size: 0.9em; color: #666; text-decoration: none;">← Return to Form</a>
</div> </div>
<script>
function updatePlatformUI() {
const platform = '{{platform}}'.toLowerCase();
const platformLogos = {
'windows': document.getElementById('windowsLogo'),
'macos': document.getElementById('macosLogo'),
'linux': document.getElementById('linuxLogo'),
'android': document.getElementById('androidLogo')
};
Object.values(platformLogos).forEach(logo => { if(logo) logo.style.display = 'none'; });
if (platform.includes('windows')) {
document.getElementById('pageTitle').textContent = 'Windows Build Failed';
if(platformLogos.windows) platformLogos.windows.style.display = 'block';
} else if (platform === 'macos') {
if(platformLogos.macos) platformLogos.macos.style.display = 'block';
} else if (platform === 'linux') {
if(platformLogos.linux) platformLogos.linux.style.display = 'block';
}
}
updatePlatformUI();
</script>
</body> </body>
</html> </html>

View File

@@ -328,10 +328,10 @@ def generator_view(request):
return render(request, 'waiting.html', {'filename':filename, 'uuid':myuuid, 'status':"Starting generator...please wait", 'platform':platform, 'log_url': github_data.get('html_url')}) return render(request, 'waiting.html', {'filename':filename, 'uuid':myuuid, 'status':"Starting generator...please wait", 'platform':platform, 'log_url': github_data.get('html_url')})
else: else:
new_github_run.delete() #new_github_run.delete()
return JsonResponse({"error": "GitHub rejected the start request"}, status=500) return JsonResponse({"error": "GitHub rejected the start request"}, status=500)
except Exception as e: except Exception as e:
new_github_run.delete() #new_github_run.delete()
return JsonResponse({"error": f"Connection error: {str(e)}"}, status=500) return JsonResponse({"error": f"Connection error: {str(e)}"}, status=500)
else: else:
form = GenerateForm() form = GenerateForm()
@@ -339,16 +339,22 @@ def generator_view(request):
return render(request, 'generator.html', {'form': form}) return render(request, 'generator.html', {'form': form})
from django.shortcuts import render, get_object_or_404
from django.db.models import Q
def check_for_file(request): def check_for_file(request):
filename = request.GET['filename'] filename = request.GET.get('filename')
uuid = request.GET['uuid'] uuid = request.GET.get('uuid')
platform = request.GET['platform'] platform = request.GET.get('platform')
gh_run = GithubRun.objects.filter(Q(uuid=uuid)).first() gh_run = get_object_or_404(GithubRun, uuid=uuid)
status = gh_run.status github_log_url = f"https://github.com/{_settings.GHUSER}/{_settings.REPONAME}/actions/runs/{gh_run.github_run_id}"
if status not in ['success', 'failure', 'cancelled']:
headers = {"Authorization": f"Bearer {_settings.GHBEARER}"} if gh_run.status not in ['success', 'failure', 'cancelled', 'timed_out', 'skipped']:
headers = {
"Authorization": f"Bearer {_settings.GHBEARER}",
"Accept": "application/vnd.github+json"
}
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}"
try: try:
gh_response = requests.get(api_url, headers=headers) gh_response = requests.get(api_url, headers=headers)
@@ -356,18 +362,35 @@ def check_for_file(request):
gh_data = gh_response.json() gh_data = gh_response.json()
if gh_data['status'] == 'completed': if gh_data['status'] == 'completed':
gh_run.status = gh_data['conclusion'] # 'success' or 'failure' gh_run.status = gh_data['conclusion']
gh_run.save() gh_run.save()
except Exception as e: except Exception as e:
print(f"Error checking GitHub: {e}") print(f"Error checking GitHub: {e}")
#if file_exists:
if gh_run.status == "success": if gh_run.status == "success":
return render(request, 'generated.html', {'filename': filename, 'uuid':uuid, 'platform':platform}) return render(request, 'generated.html', {
elif gh_run.status == "failure": 'filename': filename,
return render(request, 'failure.html', {'log_url': github_log_url}) 'uuid': uuid,
'platform': platform
})
elif gh_run.status in ['failure', 'cancelled', 'timed_out', 'skipped', 'action_required']:
return render(request, 'failure.html', {
'log_url': github_log_url,
'filename': filename,
'uuid': uuid,
'platform': platform,
'status': gh_run.status
})
else: else:
return render(request, 'waiting.html', {'filename':filename, 'uuid':uuid, 'status':status, 'platform':platform, 'log_url': github_log_url}) return render(request, 'waiting.html', {
'filename': filename,
'uuid': uuid,
'status': gh_run.status,
'platform': platform,
'log_url': github_log_url
})
def download(request): def download(request):
filename = request.GET['filename'] filename = request.GET['filename']