Skip to content

sources

sources #2

Workflow file for this run

#
# Copyright (C) 2022 Ing <https://github.com/wjz304>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
name: sources
on:
schedule:
- cron: "0 12 * * *" # 每天 12:00 UTC 时间运行一次 (北京时间每天 20:00)
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Init Env
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Asia/Shanghai"
- name: Get thirdPartySources
shell: python
run: |
import json, urllib.request
headers = {
"Authorization": f"Bearer ${{ secrets.GITHUB_TOKEN }}",
"Accept": "application/vnd.github+json",
"X-GitHub-Api-Version": "2026-03-10",
}
def query_github(url):
req = urllib.request.Request(url, headers=headers)
with urllib.request.urlopen(req, timeout=30) as resp:
return json.loads(resp.read().decode())
print("Querying non-fork repos...")
data1 = query_github(
"https://api.github.com/search/code?q=filename:fnpack.json&per_page=100"
)
print("Querying fork repos...")
data2 = query_github(
"https://api.github.com/search/code?q=filename:fnpack.json+fork:true&per_page=100"
)
entries = []
for data in [data1, data2]:
for item in data.get("items", []):
fn = item.get("repository", {}).get("full_name", "")
if fn and fn not in [e["name"] for e in entries]:
entries.append(
{
"name": fn,
"url": f"https://raw.githubusercontent.com/{fn}/refs/heads/main/fnpack.json",
"enabled": False,
}
)
entries.sort(key=lambda x: x["name"])
with open("${{ github.workspace }}/fn-appdownload/thirdPartySources.json", "w") as f:
json.dump(entries, f, ensure_ascii=False, indent=2)
print("Done:", len(entries), "entries")
- name: Check and Push
if: success()
run: |
echo "Git push ..."
# git checkout main
git pull
status=$(git status -s | grep -E "fn-appdownload/thirdPartySources.json" | awk '{printf " %s", $2}')
if [ -n "${status}" ]; then
git add ${status}
git commit -m "update $(date +%Y-%m-%d" "%H:%M:%S)"
git push -f
fi