diff --git a/.github/workflows/update_project_list.yml b/.github/workflows/update_project_list.yml new file mode 100644 index 00000000..6faeabab --- /dev/null +++ b/.github/workflows/update_project_list.yml @@ -0,0 +1,45 @@ +name: Projects healthcheck + +on: + schedule: + - cron: "0 0/4 * * *" + workflow_dispatch: + pull_request: + +env: + SUBQUERY_TOKEN: ${{ secrets.SUBQUERY_TOKEN }} + TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} + TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} + +permissions: + contents: write + pull-requests: write + +jobs: + generate_project_list: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install python dependencies + run: | + python -m pip install --upgrade pip + pip install -r ./scripts/python_scripts/requirements.txt + + - name: Generate table + run: python ./scripts/python_scripts/generate_network_status.py + + - uses: actions/checkout@v2 + with: + ref: gh-pages + path: gh-pages + + - name: Copy table to gh-pages + run: mv ./gh-pages-temp/README.md ./gh-pages/README.md + + - name: Deploy report to Github Pages + uses: peaceiris/actions-gh-pages@v2 + env: + PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PUBLISH_BRANCH: gh-pages + PUBLISH_DIR: gh-pages diff --git a/scripts/python_scripts/table_representation.py b/scripts/python_scripts/table_representation.py index e3a626ed..34a3fe86 100644 --- a/scripts/python_scripts/table_representation.py +++ b/scripts/python_scripts/table_representation.py @@ -81,14 +81,22 @@ def generate_progress_status(self, project: SubQueryProject): def fill_status_bar(self, instance: DeploymentInstance, project: SubQueryProject): if not instance: - return '![0](https://progress-bar.dev/0?title=N/A)', '-' + return 'N/A', '-' commit = instance.version[0:8] if instance.status == 'processing': - return '![0](https://progress-bar.dev/0?title=Processing...)', commit + return 'Processing...', commit if instance.status == 'error' and self.get_sync_percentage(instance, project) == '0': - return '![0](https://progress-bar.dev/0?title=Error)', commit + return 'Error', commit percent = self.get_sync_percentage(instance, project) - return f'![{percent}](https://progress-bar.dev/{percent}?title={instance.type.capitalize()})', commit + percent = min(int(percent), 100) + progress_bar = self.generate_progress_bar(percent) + return f'{progress_bar} {percent}%', commit + + def generate_progress_bar(self, percent: int) -> str: + bar_length = 5 + filled_length = int(bar_length * percent // 100) + bar = '█' * filled_length + '-' * (bar_length - filled_length) + return f'[{bar}]' def is_sync_status_valid(self, sync_status): if sync_status is None: