Skip to content

Update instance workflow to mention manifest (#847) #55

Update instance workflow to mention manifest (#847)

Update instance workflow to mention manifest (#847) #55

Workflow file for this run

name: instances
on:
push:
branches:
- develop
workflow_dispatch:
jobs:
instances:
name: Instances
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Query Instances
run: |
# Query the list of instances
curl -H 'Content-Type: application/json' -X POST \
-d '{"query": "query {nodes(softwarename: \"lemmy\") {domain active_users_monthly}}"}' https://api.fediverse.observer 2> /dev/null | \
jq -r '.data.nodes | .[] | select(.active_users_monthly > 50) | .domain' > lemmy-instances.txt.tmp
# Combine the output with the existing instances.txt file.
sort lemmy-instances.txt lemmy-instances.txt.tmp | uniq -i > lemmy-instances.txt
# Delete the temp file
rm lemmy-instances.txt.tmp
# Convert the text file to a dart file
cat << EOF > lib/instances.dart
const List<String> instances = [
$(awk '{ print " \047"$0"\047," }' lemmy-instances.txt)
];
EOF
# Put the instances in the Android manifest file
manifestInstances="$(awk '{ print " <data android:host=\""$0"\" />" }' lemmy-instances.txt)"
inSection=false
while IFS= read -r line; do
if [[ $line == *"#AUTO_GEN_INSTANCE_LIST_DO_NOT_TOUCH#"* ]]; then
inSection=true
fi
if [[ $line == *"#INSTANCE_LIST_END#"* ]]; then
echo "$manifestInstances" >> android/app/src/main/AndroidManifest-new.xml
inSection=false
fi
if [[ $line == *"android:host"* ]]; then
if [ "$inSection" = true ]; then
continue
fi
fi
echo "$line" >> android/app/src/main/AndroidManifest-new.xml
done < android/app/src/main/AndroidManifest.xml
mv android/app/src/main/AndroidManifest-new.xml android/app/src/main/AndroidManifest.xml
- name: Create Pull Request
uses: peter-evans/[email protected]
with:
commit-message: Update instances
title: Update instances
body: This PR is updating `lemmy-instances.txt`, `instances.dart`, and `AndroidManifest.xml` with the latest list of instances retrieved from fediverse.observer.
branch: update-instances
delete-branch: true
author: GitHub <[email protected]>