mirror of
https://github.com/stan220/flathub.git
synced 2026-09-08 18:29:08 +00:00
Add workflow to close issues
This commit is contained in:
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from github import Github, Auth, GithubException
|
||||
|
||||
GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN")
|
||||
|
||||
if not GITHUB_TOKEN:
|
||||
print("GITHUB_TOKEN not set")
|
||||
sys.exit(1)
|
||||
|
||||
auth = Auth.Token(GITHUB_TOKEN)
|
||||
g = Github(auth=auth)
|
||||
|
||||
query = (
|
||||
f'is:issue is:open author:flathubbot created:>=2026-02-17 '
|
||||
'("Stable commit job failed" OR '
|
||||
'"Beta commit job failed" OR '
|
||||
'"Stable publish job failed" OR '
|
||||
'"Beta publish job failed")'
|
||||
)
|
||||
|
||||
issues = g.search_issues(query)
|
||||
|
||||
checked = 0
|
||||
closed = 0
|
||||
|
||||
for issue in issues:
|
||||
checked += 1
|
||||
repo_name = issue.repository.full_name
|
||||
|
||||
print(f"[{repo_name}] Closing #{issue.number}: {issue.title}")
|
||||
|
||||
try:
|
||||
issue.edit(state="closed")
|
||||
closed += 1
|
||||
time.sleep(0.5)
|
||||
except GithubException as e:
|
||||
print(f"Failed to close #{issue.number}: {e}")
|
||||
continue
|
||||
|
||||
print(f"Issues checked: {checked}")
|
||||
print(f"Issues closed: {closed}")
|
||||
@@ -0,0 +1,23 @@
|
||||
name: Close Flathubbot Failure Issues
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
close-issues:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# 4.2.2
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip3 install 'PyGithub==2.3.0'
|
||||
|
||||
- name: Run script
|
||||
run: python3 .github/scripts/close_job_failure_issues.py
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.FLATHUBBOT_TOKEN }}
|
||||
Reference in New Issue
Block a user