name: Generate man pages on: push: paths: - "Base/usr/share/man/**" - "Meta/Websites/man.serenityos.org/**" env: MAN_DIR: ${{ github.workspace }}/Base/usr/share/man/ jobs: convert_using_pandoc: runs-on: ubuntu-20.04 if: always() && github.repository == 'SerenityOS/serenity' && github.ref == 'refs/heads/master' steps: - uses: actions/checkout@v2 - uses: r-lib/actions/setup-pandoc@v1 with: pandoc-version: '2.13' - name: Prepare output directories run: | for d in $MAN_DIR*/; do dir_name=$(basename "$d") mkdir -p output/${dir_name/man} done - name: Convert markdown to html run: | cat << EOF > link-fixup.lua function Link(el) el.target = string.gsub(el.target, "%.md", ".html") -- fixup .md to .html links el.target = string.gsub(el.target, "man", "", 1) -- fixup man1/???.html to 1/???.html links return el end EOF find $MAN_DIR -iname '*.md' -type f -exec sh -c 'relative_path=$(realpath --relative-to=$MAN_DIR $0) && stripped_path=${relative_path#man} && pandoc -f gfm -t html5 -s --lua-filter=link-fixup.lua -o output/${stripped_path%.md}.html ${0}' {} \; - name: Generate man page listings run: | for d in output/*/; do dir_name=$(basename "$d") echo "$dir_name" > "$d/index.html" for f in $d/*; do file_name=$(basename "$f") if [[ "$file_name" == "index.html" ]]; then continue fi echo "

${file_name%.html}

" >> "$d/index.html" done echo "" >> "$d/index.html" done - name: Copy pre-made files run: | cp -R Meta/Websites/man.serenityos.org/* output/ - name: Deploy to github pages uses: JamesIves/github-pages-deploy-action@4.1.1 with: git-config-name: BuggieBot git-config-email: buggiebot@serenityos.org branch: master repository-name: SerenityOS/manpages-website token: ${{ secrets.BUGGIEBOT }} folder: output