Skip to content

Scrape Neovim Themes #12

Scrape Neovim Themes

Scrape Neovim Themes #12

Workflow file for this run

name: Scrape Neovim Themes
on:
schedule:
- cron: '0 0 * * *' # Run daily at midnight
workflow_dispatch: # Allow manual triggers
jobs:
scrape:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests beautifulsoup4 PyYAML
- name: Scrape themes
run: |
cat > scrape.py << 'EOF'
from bs4 import BeautifulSoup
import requests
import re
def scrape_themes():
url = "https://dotfyle.com/neovim/colorscheme/top"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
plugin_links = soup.find_all("a", href=re.compile(r"^/plugins/"))
with open("themes.lua", "w") as file:
for link in plugin_links:
file.write("\"")
file.write(link.get("href").replace("/plugins/", ""))
file.write("\"\n")
url = "https://dotfyle.com/neovim/colorscheme/top?page=2"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
plugin_links = soup.find_all("a", href=re.compile(r"^/plugins/"))
with open("themes.lua", "a") as file:
for link in plugin_links:
file.write("\"")
file.write(link.get("href").replace("/plugins/", ""))
file.write("\"\n")
if __name__ == "__main__":
themes = scrape_themes()
EOF
python scrape.py
- name: Commit and push if changed
run: |
git config user.email "[email protected]"
git config user.name "GitHub Action"
git add themes.lua
if ! git diff --cached --quiet; then
git commit -m "Update themes from GitHub Action"
git push
else
echo "No changes detected; skipping commit."
fi