diff options
| author | Ben Busby <noreply+git@benbusby.com> | 2021-11-26 09:12:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-26 09:12:46 -0700 |
| commit | 8e3455a7901aad415eded19218edbed826a2fca5 (patch) | |
| tree | 3d6e096822bb8a51794df0c97a4eecc4f227ba9e /.github | |
| parent | ff97d258f0ac2bbd3b89df892ce3aed08b5e0a42 (diff) | |
| download | farside-8e3455a7901aad415eded19218edbed826a2fca5.tar.gz | |
Automate updates for list of searx instances (#3)
* Create nightly update workflow for instances
A nightly GitHub Actions CI workflow has been added to fetch new
instances of supported services within Farside.
Currently only Searx is supported, but obviously others could be added
if there are similarly easy ways to fetch and filter instances
programmatically.
services.json has also been updated with the initial results of the
workflow script.
* Set headers for every HTTPoison request
This serves as a workaround for bot blocking via filtron.
* Expand filtering of searx instances
New filter enforces:
- No Cloudflare
- Good TLS config
- Good HTTP header config
- Vanilla instances or forks
- Instances with 100% search success
Diffstat (limited to '.github')
| -rw-r--r-- | .github/workflows/update-instances.yml | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/.github/workflows/update-instances.yml b/.github/workflows/update-instances.yml new file mode 100644 index 0000000..d16bddd --- /dev/null +++ b/.github/workflows/update-instances.yml @@ -0,0 +1,68 @@ +on: + schedule: + - cron: '0 0 * * *' + +jobs: + update-instances: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: sudo apt-get install -y jq + - name: Fetch instances + run: | + function apply_update() { + mv services-tmp.json services.json + rm -f *-tmp.json + + # Ensure no trailing slashes for any instance + sed -i '' 's/\/"/"/g' services.json + } + + # ============================================================== + # Git config + # ============================================================== + git config --global user.name github-actions + git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com + git remote set-url origin git@github.com:benbusby/farside.git + git checkout main + + # ============================================================== + # Searx update + # ============================================================== + curl -s https://searx.space/data/instances.json | \ + jq '[ + .instances | + to_entries[] | + select(.value.network_type == "normal") | + select(.value.version | . != null) | + select(.value.version | startswith("1.0.0")) | + select(.value.network.asn_privacy == 0) | + select(.value.http.error == null) | + select(.value.tls.grade == "A+" or .value.tls.grade == "A") | + select(.value.http.grade == "A+" or .value.http.grade == "A") | + select(.value.html.grade == "V" or .value.html.grade == "F") | + .key + ] | sort' > searx-tmp.json + + jq --slurpfile searx searx-tmp.json \ + '( .[] | select(.type == "searx") ) + .instances |= $searx[0]' services.json > services-tmp.json + + apply_update + + # ============================================================== + # TODO: Update instances for other services + # ============================================================== + + # ============================================================== + # Push changes + # ============================================================== + if [[ $(git diff-index --quiet HEAD) ]]; then + echo "No updates" + else + git add services.json + git commit -m '[CI] Auto update instances' + git push + fi |
