From 89dcfb429b36a2b6ff3e3e68cd5f1847b99e5838 Mon Sep 17 00:00:00 2001 From: Nikhil Badyal Date: Sun, 29 Jun 2025 08:48:36 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Better=20App=20checker=20which=20up?= =?UTF-8?q?dates=20existing=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/newapp-check.yml | 91 ++++++++++++++++++++++++------ scripts/status_check.py | 4 +- src/downloader/sources.py | 2 +- 3 files changed, 78 insertions(+), 19 deletions(-) diff --git a/.github/workflows/newapp-check.yml b/.github/workflows/newapp-check.yml index a3f512a..8e271ab 100644 --- a/.github/workflows/newapp-check.yml +++ b/.github/workflows/newapp-check.yml @@ -4,26 +4,28 @@ on: schedule: - cron: "0 0 * * *" workflow_dispatch: - inputs: - CREATE_ISSUE: - description: "Create GitHub issue" - required: false - type: boolean - default: false + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + issues: write jobs: status_check: if: github.repository == 'nikhilbadyal/docker-py-revanced' runs-on: ubuntu-latest steps: - - name: checkout repo content + - name: Checkout repository uses: actions/checkout@main - name: Setup python uses: actions/setup-python@main with: python-version: '3.x' - cache: 'pip' # Enable caching for pip dependencies + cache: 'pip' - name: Install Requirements run: | @@ -50,12 +52,69 @@ jobs: path: status.md if-no-files-found: error - - name: Create Issue Action - if: inputs.CREATE_ISSUE - uses: nashmaniac/create-issue-action@v1.2 + - name: Update or Create Revanced Status Issue + uses: actions/github-script@v7.0.1 with: - title: Revanced apps Status - token: ${{secrets.GITHUB_TOKEN}} - assignees: ${{ github.repository_owner }} - labels: πŸ’β€new-app - body: ${{ steps.status.outputs.changelog }} + script: | + const issueTitle = 'Revanced apps Status'; + const statusContent = `${{ steps.status.outputs.changelog }}`; + + // Search for existing issue with the specific title + const issues = await github.rest.issues.listForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + labels: 'πŸ’β€new-app' + }); + + const existingIssue = issues.data.find(issue => + issue.title === issueTitle + ); + + if (existingIssue) { + // Update existing issue + const updateBody = [ + statusContent, + '', + '---', + `*Last updated: ${new Date().toISOString().split('T')[0]} by automated workflow*` + ].join('\n'); + + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: existingIssue.number, + body: updateBody + }); + + // Add a comment to show the update + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: existingIssue.number, + body: `πŸ”„ **Status Updated** - ${new Date().toISOString().split('T')[0]}\n\nThe Revanced apps status has been refreshed with the latest information.` + }); + + console.log(`Updated existing issue #${existingIssue.number}: ${issueTitle}`); + } else { + // Create new issue if none exists + const createBody = [ + statusContent, + '', + '---', + `*Created: ${new Date().toISOString().split('T')[0]} by automated workflow*`, + '', + 'This issue will be automatically updated daily with the latest Revanced apps status.' + ].join('\n'); + + const newIssue = await github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: issueTitle, + body: createBody, + assignees: [context.repo.owner], + labels: ['πŸ’β€new-app'] + }); + + console.log(`Created new issue #${newIssue.data.number}: ${issueTitle}`); + } diff --git a/scripts/status_check.py b/scripts/status_check.py index 32205db..e604112 100644 --- a/scripts/status_check.py +++ b/scripts/status_check.py @@ -25,7 +25,6 @@ from src.exceptions import ( APKMonkIconScrapError, APKPureIconScrapError, BuilderError, - ScrapingError, ) from src.patches import Patches from src.utils import apkmirror_status_check, bs4_parser, handle_request_response, request_header, request_timeout @@ -158,11 +157,12 @@ def icon_scrapper(package_name: str) -> str: } for scraper_name, error_type in scraper_names.items(): + # noinspection PyBroadException try: return str(globals()[scraper_name](package_name)) except error_type: pass - except ScrapingError: + except Exception: # noqa: BLE001,S110 pass return not_found_icon diff --git a/src/downloader/sources.py b/src/downloader/sources.py index c70599f..b546d12 100644 --- a/src/downloader/sources.py +++ b/src/downloader/sources.py @@ -16,7 +16,7 @@ PLAY_STORE_BASE_URL = "https://play.google.com" PLAY_STORE_APK_URL = f"{PLAY_STORE_BASE_URL}/store/apps/details?id=" + "{}" APK_COMBO_BASE_URL = "https://apkcombo.com" APK_COMBO_GENERIC_URL = APK_COMBO_BASE_URL + "/genericApp/{}" -not_found_icon = "https://img.icons8.com/bubbles/500/android-os.png" +not_found_icon = "https://www.svgrepo.com/download/441689/page-not-found.svg" revanced_api = "https://api.revanced.app/v4/patches/list" APK_MONK_BASE_URL = "https://www.apkmonk.com" APKEEP = "apkeep"