Skip to content

Commit

Permalink
fix github pages deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
baloola committed Aug 24, 2024
1 parent d60e2c7 commit 9a771a4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/deploy_pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,19 @@ jobs:
fi
echo "sudan-house-training.at" > naucse_build/CNAME
- name: Deploy github pages
uses: JamesIves/github-pages-deploy-action@v4
- name: Fix hrefs paths
run: |
python path_fixer.py
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
folder: naucse_build
# Upload entire repository
path: './naucse_build/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

- name: Cleanup
if: always()
Expand Down
34 changes: 34 additions & 0 deletions path_fixer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os
import re

def extract_hrefs_and_srcs(folder_path):
"""
Extracts href and src attributes from HTML files within a specified folder and its subfolders.
Args:
folder_path: The path to the folder containing HTML files.
Returns:
A list of tuples, where each tuple contains the href and src attributes of an HTML element.
"""

hrefs_and_srcs = []

for root, dirs, files in os.walk(folder_path):
for file in files:
if file.endswith(".html"):
file_path = os.path.join(root, file)
with open(file_path, 'r') as f:
content = f.read()

new_content = re.sub(r'(href|src)="(/)', r'\1="https://baloola.github.io/sudan-house/', content)

with open(file_path, 'w') as f:
f.write(new_content)

return hrefs_and_srcs

# Example usage
folder_path = "./naucse_build"
results = extract_hrefs_and_srcs(folder_path)
print(results)

0 comments on commit 9a771a4

Please sign in to comment.