Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add github pages #1273

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
33 changes: 33 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- run: ./pages_create.sh
- uses: actions/upload-pages-artifact@v3
with:
path: pages
deploy:
needs: build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
timeout-minutes: 1
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages # Deploy to the github-pages environment
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ luac.out

# MacOS
.DS_Store

pages
49 changes: 49 additions & 0 deletions pages_create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -xeuo pipefail
cd "$(dirname "$(readlink -f "$0")")"
mkdir -vp pages
repourl="${GITHUB_SERVER_URL:-https://github.com}/${GITHUB_REPOSITORY:-AstroNvim/astrocommunity}/tree/main"

{
# Generate pandoc metadata file.
cat <<EOF
---
title: "[AstroNvim Community Repository Pages]($repourl)"
date: $(LC_ALL=C date --utc)
abstract: |
Autogenerated site from README.md of all the plugins in astrocommunity repository.
---
EOF
} >pages/metadata.yaml

{
# Generate markdown of all descriptions.
prevsection=
shopt -s globstar
for readme in lua/astrocommunity/**/README.md; do
IFS=/ read -r _ _ section name _ <<<"$readme"
if [[ "$prevsection" != "$section" ]]; then
echo "# [$section]($repourl/lua/astrocommunity/$section)"
echo
prevsection=$section
fi
cat <<EOF
## [$section.$name]($repourl/lua/astrocommunity/$section/$name/init.lua)

\`\`\`
{ import = "astrocommunity.$section.$name" }
\`\`\`

EOF
# Indent markdown sections two sections up.
sed "s/^#/###/" <"$readme"
echo
done
} >pages/index.md

# Use pandoc to convert from markdown to html.
docker run -i --rm --mount type=bind,source="$PWD",target="$PWD",readonly --workdir "$PWD" pandoc/core:3.5 \
--from markdown --standalone --toc --toc-depth 2 --number-sections \
--metadata-file pages/metadata.yaml pages/index.md >pages/index.html

echo "SUCCESS - generated pages/index.html"
Loading