mirror of
https://github.com/tiennm99/cv.git
synced 2026-09-15 06:19:57 +00:00
[Change] use index.html
This commit is contained in:
Vendored
-51
@@ -1,51 +0,0 @@
|
||||
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><body><ul></ul></body></html>", "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: .
|
||||
@@ -0,0 +1 @@
|
||||
.idea
|
||||
@@ -0,0 +1,22 @@
|
||||
<html lang="vi">
|
||||
<body>
|
||||
<script>
|
||||
const owner = `tiennm99`;
|
||||
const repo = `cv`;
|
||||
const url = `https://api.github.com/repos/${owner}/${repo}/contents/`;
|
||||
fetch(url).then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error("HTTP error " + response.status);
|
||||
}
|
||||
return response.json();
|
||||
}).then(data => {
|
||||
let htmlString = "<ul>";
|
||||
for (let file of data) {
|
||||
htmlString += `<li><a href="${file.path}">${file.name}</a></li>`;
|
||||
}
|
||||
htmlString += "</ul>";
|
||||
document.getElementsByTagName("body")[0].innerHTML = htmlString;
|
||||
}).catch(error => console.error("Error:", error));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user