From 52a5d29edf9b644c922412fa94c40580f1e0fdc6 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Fri, 30 Aug 2024 21:13:10 +0100 Subject: [PATCH 01/18] Create GH pages for PP example data --- .github/workflows/blank.yml | 118 ++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 .github/workflows/blank.yml diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml new file mode 100644 index 0000000..9a129c3 --- /dev/null +++ b/.github/workflows/blank.yml @@ -0,0 +1,118 @@ +name: Generate Pathoplexus Example Data Page + +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: Generate Pathoplexus example data list + run: | + python -c " + 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 '' + elif ext in ['.tsv', '.tab']: + return '' + elif ext in ['.py', '.js', '.css', '.html', '.json']: + return f'' + elif ext in ['.jpg', '.jpeg', '.png', '.gif', '.svg']: + return f'' + elif ext in ['.pdf', '.doc', '.docx', '.txt']: + return f'' + else: + return '' + + 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 = ''' + + + + + + Pathoplexus Example Data + + + + +
+

Pathoplexus Example Data

+ + + + + + + + + + ''' + + 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''' + + + + + + ''' + + html_content += ''' + +
File NameSizeLast Modified
{icon} {html.escape(file)}{size_str}{date_str}
+
+ + + ''' + + with open('index.html', 'w') as f: + f.write(html_content) + + generate_html() + " + + - name: Commit and push to gh-pages + run: | + git config --global user.name 'GitHub Action' + git config --global user.email 'action@github.com' + 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 From 16573427a3ab7fceba34d756fc9dc9c42a2746f2 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Fri, 30 Aug 2024 21:14:16 +0100 Subject: [PATCH 02/18] Update blank.yml --- .github/workflows/blank.yml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 9a129c3..486f87f 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -1,7 +1,9 @@ -name: Generate Pathoplexus Example Data Page +name: Generate Pathoplexus Example Data List on: push: + branches: + - main # or your default branch name jobs: build: @@ -14,9 +16,9 @@ jobs: with: python-version: '3.x' - - name: Generate Pathoplexus example data list + - name: Create Python script run: | - python -c " + cat << EOF > generate_list.py import os import html from datetime import datetime @@ -24,17 +26,17 @@ jobs: def get_file_icon(file): ext = os.path.splitext(file)[1].lower() if ext in ['.fasta', '.fa', '.fna']: - return '' + return '' elif ext in ['.tsv', '.tab']: - return '' + return '' elif ext in ['.py', '.js', '.css', '.html', '.json']: - return f'' + return f'' elif ext in ['.jpg', '.jpeg', '.png', '.gif', '.svg']: - return f'' + return f'' elif ext in ['.pdf', '.doc', '.docx', '.txt']: - return f'' + return f'' else: - return '' + return '' def generate_html(): file_list = [] @@ -106,7 +108,10 @@ jobs: 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: | From b5013ca4a449ba76044d69ee441c0a24f6da4416 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Fri, 30 Aug 2024 21:14:47 +0100 Subject: [PATCH 03/18] Update blank.yml --- .github/workflows/blank.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 486f87f..674e6eb 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -2,8 +2,7 @@ name: Generate Pathoplexus Example Data List on: push: - branches: - - main # or your default branch name + jobs: build: From e0870370fcc4d53474a54313e4543c0af6fa4d9b Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Fri, 30 Aug 2024 21:17:28 +0100 Subject: [PATCH 04/18] Update blank.yml --- .github/workflows/blank.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 674e6eb..6d46c89 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -39,7 +39,7 @@ jobs: def generate_html(): file_list = [] - for root, dirs, files in os.walk('.'): + for root, dirs, files in os.walk('./example_data/'): for file in files: if file != 'index.html' and not file.startswith('.'): path = os.path.join(root, file) From c1e308b328b2c839e70d1179922e03721c9f3f91 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Fri, 30 Aug 2024 21:19:22 +0100 Subject: [PATCH 05/18] Update and rename blank.yml to update-page.yml --- .../workflows/{blank.yml => update-page.yml} | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) rename .github/workflows/{blank.yml => update-page.yml} (88%) diff --git a/.github/workflows/blank.yml b/.github/workflows/update-page.yml similarity index 88% rename from .github/workflows/blank.yml rename to .github/workflows/update-page.yml index 6d46c89..7f2bed1 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/update-page.yml @@ -3,7 +3,6 @@ name: Generate Pathoplexus Example Data List on: push: - jobs: build: runs-on: ubuntu-latest @@ -21,6 +20,7 @@ jobs: import os import html from datetime import datetime + import shutil def get_file_icon(file): ext = os.path.splitext(file)[1].lower() @@ -39,13 +39,23 @@ jobs: def generate_html(): file_list = [] - for root, dirs, files in os.walk('./example_data/'): + 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((path, size, mtime)) + file_list.append((rel_path, size, mtime)) + + # Copy file to current directory + shutil.copy2(path, os.path.join('.', rel_path)) html_content = ''' @@ -118,5 +128,6 @@ jobs: git config --global user.email 'action@github.com' git checkout -b gh-pages git add index.html + git add example_data/* git commit -m "Update Pathoplexus example data list" || exit 0 git push -f origin gh-pages From d307ab8d0f2480d34879f721a74613137e6dab14 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Fri, 30 Aug 2024 21:21:14 +0100 Subject: [PATCH 06/18] Update update-page.yml --- .github/workflows/update-page.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-page.yml b/.github/workflows/update-page.yml index 7f2bed1..8f26768 100644 --- a/.github/workflows/update-page.yml +++ b/.github/workflows/update-page.yml @@ -3,6 +3,7 @@ name: Generate Pathoplexus Example Data List on: push: + jobs: build: runs-on: ubuntu-latest @@ -116,18 +117,28 @@ jobs: 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 'action@github.com' git checkout -b gh-pages - git add index.html - git add example_data/* - git commit -m "Update Pathoplexus example data list" || exit 0 + 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 From 137f089f89cddf099d68635ee84b415fc097f0eb Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Fri, 30 Aug 2024 21:24:09 +0100 Subject: [PATCH 07/18] Update update-page.yml --- .github/workflows/update-page.yml | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/.github/workflows/update-page.yml b/.github/workflows/update-page.yml index 8f26768..674e6eb 100644 --- a/.github/workflows/update-page.yml +++ b/.github/workflows/update-page.yml @@ -21,7 +21,6 @@ jobs: import os import html from datetime import datetime - import shutil def get_file_icon(file): ext = os.path.splitext(file)[1].lower() @@ -40,23 +39,13 @@ jobs: 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 root, dirs, files in os.walk('.'): 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)) + file_list.append((path, size, mtime)) html_content = ''' @@ -117,28 +106,17 @@ jobs: 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 'action@github.com' 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 add index.html + git commit -m "Update Pathoplexus example data list" || exit 0 git push -f origin gh-pages From 82e2d7e2714b88c59500ea939f8f00f0fa874821 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Fri, 30 Aug 2024 21:28:24 +0100 Subject: [PATCH 08/18] Update update-page.yml --- .github/workflows/update-page.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-page.yml b/.github/workflows/update-page.yml index 674e6eb..285610f 100644 --- a/.github/workflows/update-page.yml +++ b/.github/workflows/update-page.yml @@ -3,7 +3,6 @@ name: Generate Pathoplexus Example Data List on: push: - jobs: build: runs-on: ubuntu-latest @@ -39,7 +38,7 @@ jobs: def generate_html(): file_list = [] - for root, dirs, files in os.walk('.'): + for root, dirs, files in os.walk('example_data'): for file in files: if file != 'index.html' and not file.startswith('.'): path = os.path.join(root, file) @@ -89,7 +88,7 @@ jobs: date_str = datetime.fromtimestamp(mtime).strftime('%Y-%m-%d %H:%M:%S') html_content += f''' - {icon} {html.escape(file)} + {icon} {html.escape(file)} {size_str} {date_str} @@ -117,6 +116,6 @@ jobs: git config --global user.name 'GitHub Action' git config --global user.email 'action@github.com' git checkout -b gh-pages - git add index.html + git add example_data/index.html git commit -m "Update Pathoplexus example data list" || exit 0 git push -f origin gh-pages From 93789f328d8f0191835e854c85594afe319f9c73 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Fri, 30 Aug 2024 21:29:50 +0100 Subject: [PATCH 09/18] Update update-page.yml --- .github/workflows/update-page.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-page.yml b/.github/workflows/update-page.yml index 285610f..3b37a92 100644 --- a/.github/workflows/update-page.yml +++ b/.github/workflows/update-page.yml @@ -116,6 +116,6 @@ jobs: git config --global user.name 'GitHub Action' git config --global user.email 'action@github.com' git checkout -b gh-pages - git add example_data/index.html + git add index.html git commit -m "Update Pathoplexus example data list" || exit 0 git push -f origin gh-pages From 118e09633f0355d59e2742cdc66756bf6827129b Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Fri, 30 Aug 2024 21:31:27 +0100 Subject: [PATCH 10/18] Update update-page.yml --- .github/workflows/update-page.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-page.yml b/.github/workflows/update-page.yml index 3b37a92..226eaa0 100644 --- a/.github/workflows/update-page.yml +++ b/.github/workflows/update-page.yml @@ -38,7 +38,7 @@ jobs: def generate_html(): file_list = [] - for root, dirs, files in os.walk('example_data'): + for root, dirs, files in os.walk('example_files'): for file in files: if file != 'index.html' and not file.startswith('.'): path = os.path.join(root, file) @@ -52,7 +52,7 @@ jobs: - Pathoplexus Example Data + Pathoplexus Example Files

Pathoplexus Example Files

+
+ {readme_content} +
From f4dfc89ced3ca310698ae5c0736d54d10b67cbb2 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Fri, 30 Aug 2024 21:45:09 +0100 Subject: [PATCH 14/18] Update update-page.yml --- .github/workflows/update-page.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-page.yml b/.github/workflows/update-page.yml index 1c713dd..ace97b7 100644 --- a/.github/workflows/update-page.yml +++ b/.github/workflows/update-page.yml @@ -2,8 +2,6 @@ name: Generate Pathoplexus Example Data List on: push: - schedule: - - cron: '0 0 * * 0' # Run weekly on Sundays at midnight jobs: build: @@ -75,7 +73,6 @@ jobs:
-

Pathoplexus Example Files

+ + +
{readme_content}
From 79643c76cf956c33a9c5cd31baf64d9ad83d08c5 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Fri, 30 Aug 2024 21:45:48 +0100 Subject: [PATCH 15/18] Update update-page.yml --- .github/workflows/update-page.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-page.yml b/.github/workflows/update-page.yml index ace97b7..a565d9b 100644 --- a/.github/workflows/update-page.yml +++ b/.github/workflows/update-page.yml @@ -81,7 +81,7 @@ jobs: a:hover {{ color: #2980b9; }} .file-icon {{ margin-right: 10px; color: #7f8c8d; }} .file-size, .file-date {{ color: #7f8c8d; font-size: 0.9em; }} - .readme-content {{ margin-bottom: 30px; padding: 20px; background-color: #f9f9f9; border-radius: 5px; }} + .readme-content {{ margin-bottom: 30px; padding: 20px; border-radius: 5px; }} .github-link {{ position: absolute; top: 10px; right: 10px; font-size: 24px; color: #333; }} From a8171248f4d0ddd44a729d5b0515d61fe529c7c3 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Sat, 31 Aug 2024 14:50:59 +0100 Subject: [PATCH 16/18] Update update-page.yml --- .github/workflows/update-page.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/update-page.yml b/.github/workflows/update-page.yml index a565d9b..2858081 100644 --- a/.github/workflows/update-page.yml +++ b/.github/workflows/update-page.yml @@ -2,6 +2,8 @@ name: Generate Pathoplexus Example Data List on: push: + branches: + main jobs: build: From 38704d757c7cbfa11518aa574ca5a387d7b9d573 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Sat, 31 Aug 2024 14:51:44 +0100 Subject: [PATCH 17/18] Update update-page.yml --- .github/workflows/update-page.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/update-page.yml b/.github/workflows/update-page.yml index 2858081..8b404ab 100644 --- a/.github/workflows/update-page.yml +++ b/.github/workflows/update-page.yml @@ -2,8 +2,7 @@ name: Generate Pathoplexus Example Data List on: push: - branches: - main + jobs: build: From bca2965cf460782b33c3a0b0bf3f647ec17c9c2c Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Sat, 31 Aug 2024 14:54:53 +0100 Subject: [PATCH 18/18] Update update-page.yml --- .github/workflows/update-page.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/update-page.yml b/.github/workflows/update-page.yml index 8b404ab..d36b623 100644 --- a/.github/workflows/update-page.yml +++ b/.github/workflows/update-page.yml @@ -2,6 +2,8 @@ name: Generate Pathoplexus Example Data List on: push: + branches: + main jobs: