mirror of
https://github.com/sherlock-project/sherlock
synced 2024-11-24 21:03:04 +00:00
Update site list to sherlockproject.xyz/sites
With these changes, the site list will be written to the sherlock-project/sherlockproject.xyz repo where the docs and everything is located. This way, we wont have to manually update the list on the website.
This commit is contained in:
parent
b80f38dcb2
commit
c5fa9d05ca
2 changed files with 22 additions and 20 deletions
31
.github/workflows/update-site-list.yml
vendored
31
.github/workflows/update-site-list.yml
vendored
|
@ -1,11 +1,11 @@
|
|||
name: Update Site List
|
||||
name: Update Site List
|
||||
|
||||
# Trigger the workflow when changes are pushed to the main branch
|
||||
# and the changes include the sherlock/resources/data.json file
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- master
|
||||
paths:
|
||||
- sherlock/resources/data.json
|
||||
|
||||
|
@ -26,24 +26,21 @@ jobs:
|
|||
- name: Install Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
python-version: '3.x'
|
||||
|
||||
# Execute the site_list.py Python script
|
||||
- name: Execute site-list.py
|
||||
run: python devel/site-list.py
|
||||
|
||||
# Commit any changes made by the script
|
||||
- name: Commit files
|
||||
run: |
|
||||
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git config --local user.name "github-actions[bot]"
|
||||
if ! git diff --exit-code; then
|
||||
git commit -a -m "Updated Site List"
|
||||
fi
|
||||
|
||||
# Push the changes to the remote repository
|
||||
- name: Push changes
|
||||
uses: ad-m/github-push-action@master
|
||||
- name: Pushes to another repository
|
||||
uses: cpina/github-action-push-to-another-repository@main
|
||||
env:
|
||||
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
|
||||
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: ${{ github.ref }}
|
||||
source-directory: 'output'
|
||||
destination-github-username: 'sherlock-project'
|
||||
commit-message: "Updated site list"
|
||||
destination-repository-name: 'sherlockproject.xyz'
|
||||
user-email: siddharth.dushantha@gmail.com
|
||||
target-branch: master
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# This module generates the listing of supported sites which can be found in
|
||||
# sites.md. It also organizes all the sites in alphanumeric order
|
||||
import json
|
||||
import os
|
||||
|
||||
# Read the data.json file
|
||||
with open("sherlock/resources/data.json", "r", encoding="utf-8") as data_file:
|
||||
|
@ -14,13 +15,16 @@ social_networks.pop('$schema', None)
|
|||
# Sort the social networks in alphanumeric order
|
||||
social_networks: list = sorted(social_networks.items())
|
||||
|
||||
# Make output dir where the site list will be written
|
||||
os.mkdir("output")
|
||||
|
||||
# Write the list of supported sites to sites.md
|
||||
with open("../sites.md", "w") as site_file:
|
||||
site_file.write(f"## List Of Supported Sites ({len(social_networks)} Sites In Total!)\n")
|
||||
with open("output/sites.mdx", "w") as site_file:
|
||||
site_file.write(f"---\ntitle: 'List of supported sites'\nsidebarTitle: 'Supported sites'\nicon: 'globe'\ndescription: 'Sherlock currently supports **400+** sites'\n---\n\n")
|
||||
for social_network, info in social_networks:
|
||||
url_main = info["urlMain"]
|
||||
is_nsfw = "**(NSFW)**" if info.get("isNSFW") else ""
|
||||
site_file.write(f"1. ![](https://www.google.com/s2/favicons?domain={url_main}) [{social_network}]({url_main}) {is_nsfw}\n")
|
||||
site_file.write(f"1. [{social_network}]({url_main}) {is_nsfw}\n")
|
||||
|
||||
# Overwrite the data.json file with sorted data
|
||||
with open("sherlock/resources/data.json", "w") as data_file:
|
||||
|
@ -29,3 +33,4 @@ with open("sherlock/resources/data.json", "w") as data_file:
|
|||
data_file.write("\n")
|
||||
|
||||
print("Finished updating supported site listing!")
|
||||
|
||||
|
|
Loading…
Reference in a new issue