From fb395d7dc4b8e3af45ea54aaeb8fce231ee3e2a4 Mon Sep 17 00:00:00 2001 From: bbhtt Date: Tue, 24 Feb 2026 00:58:14 +0530 Subject: [PATCH] Add workflow to close issues --- .github/scripts/close_job_failure_issues.py | 45 +++++++++++++++++++ .../workflows/close-job-failure-issues.yml | 23 ++++++++++ 2 files changed, 68 insertions(+) create mode 100755 .github/scripts/close_job_failure_issues.py create mode 100644 .github/workflows/close-job-failure-issues.yml diff --git a/.github/scripts/close_job_failure_issues.py b/.github/scripts/close_job_failure_issues.py new file mode 100755 index 0000000..ee70cf5 --- /dev/null +++ b/.github/scripts/close_job_failure_issues.py @@ -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}") diff --git a/.github/workflows/close-job-failure-issues.yml b/.github/workflows/close-job-failure-issues.yml new file mode 100644 index 0000000..32a8aa3 --- /dev/null +++ b/.github/workflows/close-job-failure-issues.yml @@ -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 }}