From a7227ca71566df0ad9f3ea2df289d4e4028519f6 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sun, 28 Jan 2024 11:08:32 +1100 Subject: [PATCH] Sponsorship auto-generate v0.1 + docs --- .github/workflows/update_sponsors.yml | 18 ++++++ .github/workflows/update_sponsors_table.yml | 31 ++++++++++ README.md | 30 ++++++--- update_sponsors.py | 67 +++++++++++++++++++++ update_sponsors_requirements.txt | 1 + 5 files changed, 138 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/update_sponsors.yml create mode 100644 .github/workflows/update_sponsors_table.yml create mode 100644 update_sponsors.py create mode 100644 update_sponsors_requirements.txt diff --git a/.github/workflows/update_sponsors.yml b/.github/workflows/update_sponsors.yml new file mode 100644 index 00000000..eda19ac4 --- /dev/null +++ b/.github/workflows/update_sponsors.yml @@ -0,0 +1,18 @@ +name: Update Sponsors + +on: + schedule: + - cron: '0 0 * * *' # Set your preferred schedule + +jobs: + update-readme: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Update Sponsors + run: | + GH_TOKEN=${{ secrets.GITHUB_TOKEN }} + gh run workflow_dispatch -R $GITHUB_REPOSITORY -f update_sponsors_table.yml -t $GH_TOKEN diff --git a/.github/workflows/update_sponsors_table.yml b/.github/workflows/update_sponsors_table.yml new file mode 100644 index 00000000..0cd1cb5a --- /dev/null +++ b/.github/workflows/update_sponsors_table.yml @@ -0,0 +1,31 @@ +name: Update Sponsors Table + +on: + workflow_run: + workflows: ["Update Sponsors"] + types: + - completed + +jobs: + update-table: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r update_sponsors_requirements.txt # If you have any Python dependencies + + - name: Update Sponsors Table + run: | + python update_sponsors.py + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index c9d9cb9a..dc1c5202 100755 --- a/README.md +++ b/README.md @@ -2,22 +2,29 @@ Get visibility of what's going on on your WIFI/LAN network. Scan for devices, port changes and get alerts if unknown devices or changes are found. Write your own [Plugins](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins#readme) with auto-generated UI and in-build notification system. -[![Docker](https://img.shields.io/github/actions/workflow/status/jokob-sk/Pi.Alert/docker_prod.yml?label=Build&logo=GitHub)](https://github.com/jokob-sk/Pi.Alert/actions/workflows/docker_prod.yml) [![GitHub Committed](https://img.shields.io/github/last-commit/jokob-sk/Pi.Alert?color=40ba12&label=Committed&logo=GitHub&logoColor=fff)](https://github.com/jokob-sk/Pi.Alert) [![Docker Size](https://img.shields.io/docker/image-size/jokobsk/pi.alert?label=Size&logo=Docker&color=0aa8d2&logoColor=fff)](https://hub.docker.com/r/jokobsk/pi.alert) [![Docker Pulls](https://img.shields.io/docker/pulls/jokobsk/pi.alert?label=Pulls&logo=docker&color=0aa8d2&logoColor=fff)](https://hub.docker.com/r/jokobsk/pi.alert) -[![Docker Pushed](https://img.shields.io/badge/dynamic/json?color=0aa8d2&logoColor=fff&label=Pushed&query=last_updated&url=https%3A%2F%2Fhub.docker.com%2Fv2%2Frepositories%2Fjokobsk%2Fpi.alert%2F&logo=docker&link=http://left&link=https://hub.docker.com/repository/docker/jokobsk/pi.alert)](https://hub.docker.com/r/jokobsk/pi.alert) +[![Docker Pushed](https://img.shields.io/badge/dynamic/json?color=0aa8d2&logoColor=fff&label=Pushed&query=last_updated&url=https%3A%2F%2Fhub.docker.com%2Fv2%2Frepositories%2Fjokobsk%2Fpi.alert%2F&logo=docker&link=http://left&link=https://hub.docker.com/repository/docker/jokobsk/pi.alert)](https://hub.docker.com/r/jokobsk/pi.alert) +[![GitHub Sponsors](https://img.shields.io/github/sponsors/jokob-sk?style=social)](https://github.com/sponsors/jokob-sk) - | 🐳 [Docker hub](https://registry.hub.docker.com/r/jokobsk/pi.alert) | πŸ“‘ [Docker guide](https://github.com/jokob-sk/Pi.Alert/blob/main/dockerfiles/README.md) |πŸ†• [Release notes](https://github.com/jokob-sk/Pi.Alert/releases) | πŸ“š [All Docs](https://github.com/jokob-sk/Pi.Alert/tree/main/docs) | + | 🐳 [Docker hub](https://registry.hub.docker.com/r/jokobsk/pi.alert) | πŸ“‘ [Docker guide](https://github.com/jokob-sk/Pi.Alert/blob/main/dockerfiles/README.md) |πŸ†• [Release notes](https://github.com/jokob-sk/Pi.Alert/releases) | πŸ“š [All Docs](https://github.com/jokob-sk/Pi.Alert/tree/main/docs) | |----------------------|----------------------| ----------------------| ----------------------| + + | ![Main screen][main] | ![Screen 1][screen1] | ![Screen 5][screen5] | + |----------------------|----------------------| ----------------------| + | ![Screen 3][screen3] | ![Screen 4][screen4] | ![Screen 6][screen6] | + | ![Screen 8][screen8] | ![Report 2][report2] | ![Screen 9][screen9] | + + ## Why PiAlert❓ Most of us don't know what's going on on our home network, but we want our family and data to be safe. _Command-line tools_ are great, but the output can be _hard to understand_ and action if you are not a network specialist. PiAlert gives you peace of mind. _Visualize and immediately report πŸ“¬_ what is going on in your network - this is the first step to enhance your _network security πŸ”_. -_PiAlert combines several network and other scanning tools πŸ” with notifications πŸ“§ into one user-friendly package πŸ“¦_. You get an overview of network device Sessions, Connected devices, Events, Presence, Down alerts, and IPs. You can schedule Nmap scans to detect changes in device ports and visualize your Network topology (even with undetectable, dummy devices). +PiAlert combines several network and other scanning tools πŸ” with notifications πŸ“§ into one user-friendly package πŸ“¦. Setup a _kill switch ☠_ for your network via a smart plug with the available [Home Assistant](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/HOME_ASSISTANT.md) integration. Implement custom automations with the [CSV device Exports πŸ“€](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins/csv_backup), [Webhooks](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/WEBHOOK_N8N.md), or [API endpoints](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/API.md) features. @@ -25,11 +32,6 @@ Extend the app if you want to create your own scanner [Plugin](https://github.co Looking forward to your contributions if you decide to share your work with the community ❀. - | ![Main screen][main] | ![Screen 1][screen1] | ![Screen 5][screen5] | - |----------------------|----------------------| ----------------------| - | ![Screen 3][screen3] | ![Screen 4][screen4] | ![Screen 6][screen6] | - | ![Screen 8][screen8] | ![Report 2][report2] | ![Screen 9][screen9] | - ## Scan Methods, Notifications, Integration, Extension system | Features | Details | @@ -72,6 +74,16 @@ Looking forward to your contributions if you decide to share your work with the > πŸ“§ Email me at [jokob@duck.com](mailto:jokob@duck.com?subject=PiAlert) if you want to get in touch or if I should add other sponsorship platforms. +### ⭐ Sponsors + +Thank you to all the wonderful people who have sponsored (=burnout prevention) this project: + + + + + + + ## Everything else diff --git a/update_sponsors.py b/update_sponsors.py new file mode 100644 index 00000000..71f1bd47 --- /dev/null +++ b/update_sponsors.py @@ -0,0 +1,67 @@ +import os +import requests + +def fetch_sponsors(): + repo_owner = "jokob-sk" + repo_name = "Pi.Alert" + api_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/sponsors" + + headers = { + "Authorization": f"Bearer {os.environ.get('GH_TOKEN')}", + "Accept": "application/vnd.github.v3+json", + } + + current_sponsors = [] + past_sponsors = [] + + page = 1 + while True: + params = {"page": page} + response = requests.get(api_url, headers=headers, params=params) + data = response.json() + + if not data: + break + + for sponsor in data: + if sponsor["sponsorship_created_at"] == sponsor["sponsorship_updated_at"]: + past_sponsors.append(sponsor) + else: + current_sponsors.append(sponsor) + + page += 1 + + return {"current_sponsors": current_sponsors, "past_sponsors": past_sponsors} + +def generate_sponsors_table(current_sponsors, past_sponsors): + current_table = "| Current Sponsors |\n|---|\n" + for sponsor in current_sponsors: + current_table += f"| [{sponsor['login']}](https://github.com/{sponsor['login']}) |\n" + + past_table = "| Past Sponsors |\n|---|\n" + for sponsor in past_sponsors: + past_table += f"| {sponsor['login']} |\n" + + return current_table + "\n" + past_table + +def update_readme(sponsors_table): + readme_path = "README.md" + with open(readme_path, "r") as readme_file: + readme_content = readme_file.read() + + # Replace the placeholder with the generated sponsors table + updated_readme = readme_content.replace("", sponsors_table) + + with open(readme_path, "w") as readme_file: + readme_file.write(updated_readme) + +def main(): + sponsors_data = fetch_sponsors() + current_sponsors = sponsors_data.get("current_sponsors", []) + past_sponsors = sponsors_data.get("past_sponsors", []) + + sponsors_table = generate_sponsors_table(current_sponsors, past_sponsors) + update_readme(sponsors_table) + +if __name__ == "__main__": + main() diff --git a/update_sponsors_requirements.txt b/update_sponsors_requirements.txt new file mode 100644 index 00000000..309476d1 --- /dev/null +++ b/update_sponsors_requirements.txt @@ -0,0 +1 @@ +requests>=2.0.0 \ No newline at end of file