From e48f1c50eb84207c09f9705e6edf966a4b9a331a Mon Sep 17 00:00:00 2001 From: Qiusheng Wu Date: Sat, 6 Jul 2024 11:23:57 -0400 Subject: [PATCH] Update index.html --- .github/workflows/deploy.yml | 24 +++++++++++++++++ create_index.py | 51 ++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 create_index.py diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 58297b9..7014d20 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,6 +25,30 @@ jobs: with: python-version: ${{ matrix.python-version }} + ##################################################### + # Comment out this section if you don't need to generate the index.html file + - name: execute python script + run: | + python create_index.py + - name: file_check + run: ls -l -a + - name: commit files + continue-on-error: true + run: | + today=$(date +"%Y-%m-%d") + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add -A + git commit -m "Updated index.html ${today} UTC" -a + git pull origin master + - name: push changes + continue-on-error: true + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: master + ##################################################### + # Deploy the book's HTML to gh-pages branch - name: GitHub Pages action uses: peaceiris/actions-gh-pages@v4 diff --git a/create_index.py b/create_index.py new file mode 100644 index 0000000..cb2cb83 --- /dev/null +++ b/create_index.py @@ -0,0 +1,51 @@ +import os + + +def generate_index_html(directories, output_file): + # Start the HTML content + html_content = """ + + + Directory Listing + + +

Directory Listing

+ + + +""" + + # Write the HTML content to the output file + with open(output_file, "w") as f: + f.write(html_content) + + +# Specify the directories to list +directories_to_list = ["files"] +# Specify the output HTML file +output_html_file = "index.html" + +generate_index_html(directories_to_list, output_html_file)