1
0
Fork 0
mirror of https://github.com/benbusby/farside.git synced 2025-04-21 11:28:43 +00:00
farside/.github/workflows/update-instances.yml
Ben Busby 919dd6f602
Support teddit, piped, and simplytranslate
- teddit (https://teddit.net/about)
  A free and open source alternative Reddit front-end focused on
  privacy. Inspired by the Nitter project.

- Piped (https://github.com/TeamPiped/Piped)
  An alternative privacy-friendly YouTube frontend which is efficient
  by design.

- SimplyTranslate (https://simple-web.org/projects/simplytranslate.html)
  We aim to provide fast and private translations to the user without
  wasting much overhead for extensive styling or JavaScript

___

Also adds SimplyTranslate to the github pipeline, since they provide a
list of the service's public instances.

Closes #4
2021-12-15 17:12:59 -07:00

86 lines
3.1 KiB
YAML

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
- uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: |
${{ secrets.PRIMARY_REPO_KEY }}
- 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
# ==============================================================
echo "Fetching searx instances..."
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
cat searx-tmp.json | jq .
jq --slurpfile searx searx-tmp.json \
'( .[] | select(.type == "searx") )
.instances |= $searx[0]' services.json > services-tmp.json
apply_update
# ==============================================================
# Simply Translate update
# ==============================================================
curl -s https://simple-web.org/instances/simplytranslate | sort > st-out
sed -i -e 's/^/https:\/\//' st-out
jq -ncR '[inputs]' <<< "$(cat st-out)" > st-tmp.json
jq --slurpfile simplytranslate st-tmp.json \
'( .[] | select(.type == "simplytranslate") )
.instances |= $simplytranslate[0]' services.json > services-tmp.json
apply_update
# ==============================================================
# TODO: Update instances for other services
# ==============================================================
# ==============================================================
# Push changes
# ==============================================================
git add services.json
git commit -m '[CI] Auto update instances' || exit 0
git push