-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (125 loc) · 5.66 KB
/
update-page.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
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
import shutil
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 = []
example_data_dir = './example_data'
if not os.path.exists(example_data_dir):
print(f"Error: {example_data_dir} directory not found.")
return
for root, dirs, files in os.walk(example_data_dir):
for file in files:
if file != 'index.html' and not file.startswith('.'):
path = os.path.join(root, file)
rel_path = os.path.relpath(path, example_data_dir)
size = os.path.getsize(path)
mtime = os.path.getmtime(path)
file_list.append((rel_path, size, mtime))
# Copy file to current directory
shutil.copy2(path, os.path.join('.', rel_path))
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)
print(f"index.html has been created in {os.getcwd()}")
generate_html()
EOF
- name: Generate Pathoplexus example data list
run: python generate_list.py
- name: Debug - List directory contents
run: |
echo "Current directory:"
pwd
echo "Files in current directory:"
ls -la
- 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 || echo "index.html not found"
git add example_data/* || echo "No files in example_data"
git status
git commit -m "Update Pathoplexus example data list" || echo "No changes to commit"
git push -f origin gh-pages