@@ -30,6 +30,7 @@ function setup_github_authentication()
30
30
println (" • Name: 'LinearSolve Autotune'" )
31
31
println (" • Expiration: 90 days" )
32
32
println (" • Repository access: 'Public Repositories (read-only)'" )
33
+ println (" • Permissions: Enable 'Contents: Read and write', 'Pull requests: Write', 'Forks: Write'" )
33
34
println (" 4️⃣ Click 'Generate token' and copy it" )
34
35
println ()
35
36
println (" 🔑 Paste your GitHub token here:" )
@@ -401,6 +402,22 @@ function upload_to_github(content::String, plot_files::Union{Nothing, Tuple, Dic
401
402
402
403
catch e
403
404
@warn " ❌ Failed to create pull request: $e "
405
+
406
+ # Try creating an issue as fallback if it's a permissions issue
407
+ if contains (string (e), " 403" ) || contains (string (e), " permissions" ) || contains (string (e), " fork" )
408
+ @info " 💡 Attempting to create issue instead of PR due to permissions..."
409
+ try
410
+ issue_result = create_benchmark_issue (target_repo, fallback_repo, content, auth, system_info)
411
+ if issue_result != = nothing
412
+ @info " ✅ Created benchmark results issue: $(issue_result[" html_url" ]) "
413
+ @info " 🔗 Your benchmark data has been shared with the community!"
414
+ return
415
+ end
416
+ catch issue_error
417
+ @info " 💡 Could not create issue either: $issue_error "
418
+ end
419
+ end
420
+
404
421
@info " 💡 This could be due to network issues, repository permissions, or API limits."
405
422
406
423
# Save locally as fallback
@@ -411,6 +428,62 @@ function upload_to_github(content::String, plot_files::Union{Nothing, Tuple, Dic
411
428
end
412
429
end
413
430
431
+ """
432
+ create_benchmark_issue(target_repo, fallback_repo, content, auth, system_info)
433
+
434
+ Create a GitHub issue with benchmark results as a fallback when PR creation fails.
435
+ """
436
+ function create_benchmark_issue (target_repo, fallback_repo, content, auth, system_info)
437
+ try
438
+ # Try target repository first, fallback if needed
439
+ actual_repo = target_repo
440
+ repo_obj = nothing
441
+
442
+ try
443
+ repo_obj = GitHub. repo (target_repo, auth= auth)
444
+ catch
445
+ @info " 📋 Using fallback repository for issue: $fallback_repo "
446
+ actual_repo = fallback_repo
447
+ repo_obj = GitHub. repo (fallback_repo, auth= auth)
448
+ end
449
+
450
+ # Create issue title and body
451
+ cpu_name = get (system_info, " cpu_name" , " unknown" )
452
+ os_name = get (system_info, " os" , " unknown" )
453
+ timestamp = Dates. format (Dates. now (), " yyyy-mm-dd HH:MM" )
454
+
455
+ issue_title = " Benchmark Results: $cpu_name on $os_name ($timestamp )"
456
+
457
+ issue_body = """
458
+ # LinearSolve.jl Autotune Benchmark Results
459
+
460
+ **Submitted via GitHub Issue** (PR creation failed due to token permissions)
461
+
462
+ $content
463
+
464
+ ---
465
+
466
+ **Note**: This was submitted as an issue because the GitHub token lacks fork creation permissions.
467
+ To enable PR creation, please create a token with 'Contents: Read and write', 'Pull requests: Write', and 'Forks: Write' permissions.
468
+
469
+ 🤖 *Generated automatically by LinearSolve.jl autotune system*
470
+ """
471
+
472
+ # Create the issue
473
+ issue_result = GitHub. create_issue (repo_obj,
474
+ title= issue_title,
475
+ body= issue_body,
476
+ auth= auth)
477
+
478
+ @info " ✅ Created benchmark results issue #$(issue_result. number) "
479
+ return issue_result
480
+
481
+ catch e
482
+ @warn " Failed to create benchmark issue: $e "
483
+ return nothing
484
+ end
485
+ end
486
+
414
487
"""
415
488
create_result_files(folder_name, content, plot_files, results_df, system_info, categories)
416
489
@@ -598,7 +671,14 @@ function create_results_pr(target_repo, fallback_repo, branch_name, folder_name,
598
671
error (" Failed to access existing fork: $e2 " )
599
672
end
600
673
else
601
- error (" Failed to create fork: $e " )
674
+ if contains (string (e), " 403" ) && contains (string (e), " Resource not accessible by personal access token" )
675
+ @warn " GitHub token lacks fork creation permissions. Please create a new token with 'Forks: Write' permission."
676
+ @info " 📋 Token setup guide: Go to https://github.com/settings/tokens?type=beta"
677
+ @info " 📋 Enable permissions: 'Contents: Read and write', 'Pull requests: Write', 'Forks: Write'"
678
+ error (" GitHub token permissions insufficient for fork creation" )
679
+ else
680
+ error (" Failed to create fork: $e " )
681
+ end
602
682
end
603
683
end
604
684
0 commit comments