Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pages): add github pages
Browse files Browse the repository at this point in the history
Kamilcuk committed Nov 17, 2024
1 parent 9170837 commit aaaffc9
Showing 3 changed files with 81 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
on:
- push
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
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
@@ -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"

0 comments on commit aaaffc9

Please sign in to comment.