Add code to update instances automatically.

This commit is contained in:
Kavin
2022-11-12 01:56:07 +00:00
parent 9f0c8696d4
commit 70aec514a5
4 changed files with 123 additions and 28 deletions
+22
View File
@@ -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"
+56 -28
View File
@@ -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
+2
View File
@@ -0,0 +1,2 @@
httpx
pyyaml
+43
View File
@@ -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)