Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/redirects_page.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Generate and Deploy Redirects

on:
workflow_dispatch:

jobs:
build-and-deploy:
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v4

# Install Julia
- name: Install Julia
uses: julia-actions/setup-julia@v2
with:
version: '1'

# Run the Julia script
- name: Run Julia script
run: julia generate_redirects.jl

- name: Upload static files as artifact
uses: actions/upload-pages-artifact@v3
with:
path: packages/

# Deploy to GitHub Pages
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
42 changes: 42 additions & 0 deletions generate_redirects.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using TOML

function get_repo(path::String)
return TOML.parsefile(joinpath(path, "Package.toml"))["repo"]
end

function get_packages_info()
reg = TOML.parsefile("Registry.toml")
return [(; name = dict["name"], path = dict["path"]) for (uuid, dict) in reg["packages"]]
end

function create_redirect_page(; name, path)
repo = get_repo(path)
open(joinpath("packages", name * ".html"), "w") do io
write(io, """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Redirecting...</title>
<meta http-equiv="refresh" content="0; url=$repo">
</head>
<body>
<p>If you are not redirected automatically, follow this <a href="$repo">link</a>.</p>
</body>
</html>
""")
end
end

function main()
if !isdir("packages")
mkdir("packages")
end
packages_info = get_packages_info()
for (; name, path) in packages_info
create_redirect_page(; name, path)
end
end

main()