diff --git a/pdf/.github/workflows/workflow.yml b/pdf/.github/workflows/workflow.yml index 6f4c5f0..9c28440 100644 --- a/pdf/.github/workflows/workflow.yml +++ b/pdf/.github/workflows/workflow.yml @@ -1,51 +1,40 @@ -name: Generate Directory Listing and Deploy to GitHub Pages - +name: directory-listing on: [push] jobs: - build: + pages-directory-listing: runs-on: ubuntu-latest - + name: Directory Listings Index steps: - - uses: actions/checkout@v2 + - name: Checkout Repository + uses: actions/checkout@v3 + with: + ref: master #checkout different branch - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.8 + - name: Generate Directory Listings + uses: jayanta525/github-pages-directory-listing@v4.0.0 + with: + FOLDER: data #directory to generate index - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install beautifulsoup4 + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: 'data' # upload generated folder - - name: Generate Directory Listing - run: | - import os - import pathlib - from bs4 import BeautifulSoup + deploy: + needs: pages-directory-listing + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source - def create_index_html(path): - soup = BeautifulSoup("", "html.parser") - ul = soup.find("ul") + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} - 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("data") - 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: ./data + # Specify runner + deployment step + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1