From 70aec514a5a0375bf4510e4265fcbb922172f651 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Sat, 12 Nov 2022 01:56:07 +0000 Subject: [PATCH] Add code to update instances automatically. --- .github/workflows/update-instances.yml | 22 +++++++ .upptimerc.yml | 84 +++++++++++++++++--------- requirements.txt | 2 + update-instances.py | 43 +++++++++++++ 4 files changed, 123 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/update-instances.yml create mode 100644 requirements.txt create mode 100644 update-instances.py diff --git a/.github/workflows/update-instances.yml b/.github/workflows/update-instances.yml new file mode 100644 index 0000000000..2ecf4bf2f4 --- /dev/null +++ b/.github/workflows/update-instances.yml @@ -0,0 +1,22 @@ +name: Update Instance List + +on: + schedule: + - cron: "0 0 * * *" # Runs at 00:00 UTC every day + workflow_dispatch: + +jobs: + update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + - name: Install requirements + run: pip install -r requirements.txt + - name: Update Instances + run: python update-instances.py + - uses: EndBug/add-and-commit@v9 + with: + default_author: github_actions + message: "Update instances" + add: ".upptimerc.yml" diff --git a/.upptimerc.yml b/.upptimerc.yml index ef29512458..50872061be 100644 --- a/.upptimerc.yml +++ b/.upptimerc.yml @@ -1,31 +1,59 @@ -# Change these first -owner: upptime # Your GitHub organization or username, where this repository lives -repo: upptime # The name of this repository - +owner: TeamPiped +repo: piped-uptime sites: - - name: Google - url: https://www.google.com - - name: Wikipedia - url: https://en.wikipedia.org - - name: Hacker News - url: https://news.ycombinator.com - - name: Test Broken Site - url: https://thissitedoesnotexist.koj.co - +- name: kavin.rocks (Official) + url: https://pipedapi.kavin.rocks/healthcheck +- name: tokhmi.xyz + url: https://pipedapi.tokhmi.xyz/healthcheck +- name: moomoo.me + url: https://pipedapi.moomoo.me/healthcheck +- name: syncpundit.io + url: https://pipedapi.syncpundit.io/healthcheck +- name: mha.fi + url: https://api-piped.mha.fi/healthcheck +- name: whatever.social + url: https://watchapi.whatever.social/healthcheck +- name: garudalinux.org + url: https://piped-api.garudalinux.org/healthcheck +- name: rivo.lol + url: https://pipedapi.rivo.lol/healthcheck +- name: aeong.one + url: https://pipedapi.aeong.one/healthcheck +- name: kavin.rocks libre (Official) + url: https://pipedapi-libre.kavin.rocks/healthcheck +- name: jae.fi + url: https://api.yt.jae.fi/healthcheck +- name: mint.lgbt + url: https://pa.mint.lgbt/healthcheck +- name: il.ax + url: https://pa.il.ax/healthcheck +- name: privacy.com.de + url: https://piped-api.privacy.com.de/healthcheck +- name: esmailelbob.xyz + url: https://pipedapi.esmailelbob.xyz/healthcheck +- name: projectsegfau.lt + url: https://api.piped.projectsegfau.lt/healthcheck +- name: privacydev.net + url: https://api.piped.privacydev.net/healthcheck +- name: palveluntarjoaja.eu + url: https://pipedapi.palveluntarjoaja.eu/healthcheck +- name: plibre.com + url: https://p.plibre.com/healthcheck +- name: smnz.de + url: https://pipedapi.smnz.de/healthcheck +- name: adminforge.de + url: https://pipedapi.adminforge.de/healthcheck +- name: qdi.fi + url: https://pipedapi.qdi.fi/healthcheck status-website: - # Add your custom domain name, or remove the `cname` line if you don't have a domain - # Uncomment the `baseUrl` line if you don't have a custom domain and add your repo name there - cname: demo.upptime.js.org - # baseUrl: /your-repo-name - logoUrl: https://raw.githubusercontent.com/upptime/upptime.js.org/master/static/img/icon.svg - name: Upptime - introTitle: "**Upptime** is the open-source uptime monitor and status page, powered entirely by GitHub." - introMessage: This is a sample status page which uses **real-time** data from our [GitHub repository](https://github.com/upptime/upptime). No server required — just GitHub Actions, Issues, and Pages. [**Get your own for free**](https://github.com/upptime/upptime) + cname: status.piped.video + introMessage: A status page for Piped instances, with uptime and **INACCURATE** + response time information. + introTitle: Piped Instances status + logoUrl: https://raw.githubusercontent.com/uppthttps://cdn.jsdelivr.net/gh/TeamPiped/Piped@fcea986/public/img/icons/logo.svgime/upptime.js.org/master/static/img/icon.svg + name: Piped Instances Status navbar: - - title: Status - href: / - - title: GitHub - href: https://github.com/$OWNER/$REPO - -# Upptime also supports notifications, assigning issues, and more -# See https://upptime.js.org/docs/configuration + - href: / + title: Status + - href: https://github.com/$OWNER/$REPO + title: GitHub diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..f4f490cea7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +httpx +pyyaml diff --git a/update-instances.py b/update-instances.py new file mode 100644 index 0000000000..5251306141 --- /dev/null +++ b/update-instances.py @@ -0,0 +1,43 @@ +import yaml +import httpx + +# Read .uptimerc.yaml config file +with open(".upptimerc.yml", "r", encoding="UTF-8") as f: + config = yaml.safe_load(f) + +# Get the list of instances +resp = httpx.get( + "https://raw.githubusercontent.com/wiki/TeamPiped/Piped-Frontend/Instances.md") + +# Parse the list of instances +instances = [] + +skipped = 0 + +for line in resp.text.splitlines(): + + split = line.split("|") + + if len(split) < 4: + continue + + if skipped < 2: + skipped += 1 + continue + + instances.append({ + "name": split[0].strip(), + "url": split[1].strip(), + "locations": split[2].strip(), + }) + +# Update the config file +config["sites"] = [{ + "name": x["name"], + "url": f"{x['url']}/healthcheck", +} for x in instances] + + +# Write the config file +with open(".upptimerc.yml", "w", encoding="UTF-8") as f: + yaml.safe_dump(config, f)