- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
feat(pages): add github pages
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,5 @@ luac.out | |
|
||
# MacOS | ||
.DS_Store | ||
|
||
pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |