name: Generate Directory Listing and Deploy to GitHub Pages on: [push] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: python-version: 3.8 - name: Install dependencies run: | python -m pip install --upgrade pip pip install beautifulsoup4 - name: Generate Directory Listing run: | import os import pathlib from bs4 import BeautifulSoup def create_index_html(path): soup = BeautifulSoup("", "html.parser") ul = soup.find("ul") for child in sorted(path.iterdir()): li = soup.new_tag("li") a = soup.new_tag("a", href=str(child)) a.string = str(child) li.append(a) ul.append(li) with open(path / "index.html", "w") as f: f.write(str(soup)) root = pathlib.Path(".") for path in sorted(root.rglob('*')): if path.is_dir(): create_index_html(path) - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: .