Skip to content

Update blank.yml

Update blank.yml #2

Workflow file for this run

name: Generate Pathoplexus Example Data List
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.x'
- name: Create Python script
run: |
cat << EOF > generate_list.py
import os
import html
from datetime import datetime
def get_file_icon(file):
ext = os.path.splitext(file)[1].lower()
if ext in ['.fasta', '.fa', '.fna']:
return '<i class="fas fa-dna" title="FASTA file"></i>'
elif ext in ['.tsv', '.tab']:
return '<i class="fas fa-table" title="TSV file"></i>'
elif ext in ['.py', '.js', '.css', '.html', '.json']:
return f'<i class="fas fa-file-code" title="{ext[1:]} file"></i>'
elif ext in ['.jpg', '.jpeg', '.png', '.gif', '.svg']:
return f'<i class="fas fa-file-image" title="{ext[1:]} file"></i>'
elif ext in ['.pdf', '.doc', '.docx', '.txt']:
return f'<i class="fas fa-file-alt" title="{ext[1:]} file"></i>'
else:
return '<i class="fas fa-file"></i>'
def generate_html():
file_list = []
for root, dirs, files in os.walk('.'):
for file in files:
if file != 'index.html' and not file.startswith('.'):
path = os.path.join(root, file)
size = os.path.getsize(path)
mtime = os.path.getmtime(path)
file_list.append((path, size, mtime))
html_content = '''
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pathoplexus Example Data</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" rel="stylesheet">
<style>
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; padding: 20px; background-color: #f4f4f4; color: #333; }
.container { max-width: 800px; margin: 0 auto; background-color: #fff; padding: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
h1 { color: #2c3e50; text-align: center; margin-bottom: 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #e0e0e0; }
th { background-color: #f2f2f2; font-weight: bold; color: #2c3e50; }
tr:hover { background-color: #f5f5f5; }
a { color: #3498db; text-decoration: none; }
a:hover { color: #2980b9; }
.file-icon { margin-right: 10px; color: #7f8c8d; }
.file-size, .file-date { color: #7f8c8d; font-size: 0.9em; }
</style>
</head>
<body>
<div class="container">
<h1>Pathoplexus Example Data</h1>
<table>
<thead>
<tr>
<th>File Name</th>
<th>Size</th>
<th>Last Modified</th>
</tr>
</thead>
<tbody>
'''
for file, size, mtime in sorted(file_list):
icon = get_file_icon(file)
size_str = f'{size/1024:.1f} KB' if size >= 1024 else f'{size} bytes'
date_str = datetime.fromtimestamp(mtime).strftime('%Y-%m-%d %H:%M:%S')
html_content += f'''
<tr>
<td><a href="{html.escape(file)}">{icon} {html.escape(file)}</a></td>
<td class="file-size">{size_str}</td>
<td class="file-date">{date_str}</td>
</tr>
'''
html_content += '''
</tbody>
</table>
</div>
</body>
</html>
'''
with open('index.html', 'w') as f:
f.write(html_content)
generate_html()
EOF
- name: Generate Pathoplexus example data list
run: python generate_list.py
- name: Commit and push to gh-pages
run: |
git config --global user.name 'GitHub Action'
git config --global user.email '[email protected]'
git checkout -b gh-pages
git add index.html
git commit -m "Update Pathoplexus example data list" || exit 0
git push -f origin gh-pages