diff --git a/.github/workflows/update-relay-data.yml b/.github/workflows/update-relay-data.yml new file mode 100644 index 0000000..1b816ff --- /dev/null +++ b/.github/workflows/update-relay-data.yml @@ -0,0 +1,75 @@ +name: Update Relay Data + +on: + schedule: + # Run every day at 6:00 AM UTC + - cron: '0 6 * * *' + workflow_dispatch: # Allows manual triggering + push: + branches: + - main + paths: + - 'nostr_relay_discovery.py' + - 'filter_bitchat_relays.sh' + - 'relays_geo_lookup.sh' + +jobs: + update-relay-data: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Install jq + run: sudo apt-get update && sudo apt-get install -y jq + + - name: Make scripts executable + run: | + chmod +x filter_bitchat_relays.sh + chmod +x relays_geo_lookup.sh + + - name: Update relay discovery results + run: | + python3 nostr_relay_discovery.py wss://relay.damus.io --output relay_discovery_results.json + + - name: Update relay geolocation data + run: | + cat relay_discovery_results.json | jq .functioning_relays[] | ./filter_bitchat_relays.sh | sed 's|^wss://||' | ./relays_geo_lookup.sh nostr_relays.csv + + - name: Check for changes + id: git-check + run: | + git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT + + - name: Commit and push changes + if: steps.git-check.outputs.changes == 'true' + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add relay_discovery_results.json nostr_relays.csv + git commit -m "Automated update of relay data - $(date -u)" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload relay data as artifacts + uses: actions/upload-artifact@v3 + with: + name: relay-data-${{ github.run_number }} + path: | + relay_discovery_results.json + nostr_relays.csv + retention-days: 30 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a1fb46e --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +websockets>=11.0.0